xfs: consolidate superblock logging functions
We now have several superblock loggin functions that are identical except for the transaction reservation and whether it shoul dbe a synchronous transaction or not. Consolidate these all into a single function, a single reserveration and a sync flag and call it xfs_sync_sb(). Also, xfs_mod_sb() is not really a modification function - it's the operation of logging the superblock buffer. hence change the name of it to reflect this. Note that we have to change the mp->m_update_flags that are passed around at mount time to a boolean simply to indicate a superblock update is needed. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
This commit is contained in:

committed by
Dave Chinner

parent
4d11a40239
commit
61e63ecb57
@@ -753,14 +753,13 @@ xfs_initialize_perag_data(
|
||||
}
|
||||
|
||||
/*
|
||||
* xfs_mod_sb() can be used to copy arbitrary changes to the
|
||||
* in-core superblock into the superblock buffer to be logged.
|
||||
* It does not provide the higher level of locking that is
|
||||
* needed to protect the in-core superblock from concurrent
|
||||
* access.
|
||||
* xfs_log_sb() can be used to copy arbitrary changes to the in-core superblock
|
||||
* into the superblock buffer to be logged. It does not provide the higher
|
||||
* level of locking that is needed to protect the in-core superblock from
|
||||
* concurrent access.
|
||||
*/
|
||||
void
|
||||
xfs_mod_sb(
|
||||
xfs_log_sb(
|
||||
struct xfs_trans *tp)
|
||||
{
|
||||
struct xfs_mount *mp = tp->t_mountp;
|
||||
@@ -770,3 +769,35 @@ xfs_mod_sb(
|
||||
xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF);
|
||||
xfs_trans_log_buf(tp, bp, 0, sizeof(struct xfs_dsb));
|
||||
}
|
||||
|
||||
/*
|
||||
* xfs_sync_sb
|
||||
*
|
||||
* Sync the superblock to disk.
|
||||
*
|
||||
* Note that the caller is responsible for checking the frozen state of the
|
||||
* filesystem. This procedure uses the non-blocking transaction allocator and
|
||||
* thus will allow modifications to a frozen fs. This is required because this
|
||||
* code can be called during the process of freezing where use of the high-level
|
||||
* allocator would deadlock.
|
||||
*/
|
||||
int
|
||||
xfs_sync_sb(
|
||||
struct xfs_mount *mp,
|
||||
bool wait)
|
||||
{
|
||||
struct xfs_trans *tp;
|
||||
int error;
|
||||
|
||||
tp = _xfs_trans_alloc(mp, XFS_TRANS_SB_CHANGE, KM_SLEEP);
|
||||
error = xfs_trans_reserve(tp, &M_RES(mp)->tr_sb, 0, 0);
|
||||
if (error) {
|
||||
xfs_trans_cancel(tp, 0);
|
||||
return error;
|
||||
}
|
||||
|
||||
xfs_log_sb(tp);
|
||||
if (wait)
|
||||
xfs_trans_set_sync(tp);
|
||||
return xfs_trans_commit(tp, 0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user