xfs: move xfs_sync_sb_buf() out of libxfs into xfs_ioctl.c
PATCH 1/1 xfs: move xfs_sync_sb_buf() out of libxfs into xfs_ioctl.c
xfs_sync_sb_buf() dereferences mp->m_sb_bp and mp->m_rtsb_bp, which only exist in the kernel's struct xfs_mount, not in xfsprogs' libxfs. Keeping it in libxfs is a porting hazard.
Its only caller, xfs_ioc_setlabel(), is kernel-only, so move it there and make it static.
Fixes c1351fb48eee ("xfs: don't hold buffer locks across sync transaction commit in xfs_sync_sb_buf")
Suggested-by Darrick J. Wong <[email protected]>
Suggested-by Christoph Hellwig <[email protected]>
Signed-off-by Yun Zhou <[email protected]>
--- fs/xfs/libxfs/xfs_sb.c | 40 ---------------------------------------- fs/xfs/libxfs/xfs_sb.h | 1 - fs/xfs/xfs_ioctl.c | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 41 deletions(-)
fs/xfs/libxfs/xfs_sb.c +0 -40
@@ -1460,46 +1460,6 @@ xfs_update_secondary_sbs(return saved_error ? saved_error : error; } -/* -* Same behavior as xfs_sync_sb, except that it is always synchronous and it -* also writes the superblock buffer to disk sector 0 immediately. -*/ -int -xfs_sync_sb_buf ( -struct xfs_mount *mp, -bool update_rtsb) -{ -struct xfs_trans *tp; -int error; - - error =xfs_trans_alloc (mp, &M_RES (mp)->tr_sb,0 ,0 ,0 , &tp); -if (error) -return error; - -xfs_log_sb (tp); -if (update_rtsb) -xfs_log_rtsb (tp,xfs_trans_getsb (tp)); -xfs_trans_set_sync (tp); - error =xfs_trans_commit (tp); -if (error) -return error; - -/* Re-acquire and write the sb and rtsb to disk. */ -xfs_buf_lock (mp->m_sb_bp); - error =xfs_bwrite (mp->m_sb_bp); -xfs_buf_unlock (mp->m_sb_bp); -if (error) -return error; - -if (update_rtsb && mp->m_rtsb_bp) { -xfs_buf_lock (mp->m_rtsb_bp); - error =xfs_bwrite (mp->m_rtsb_bp); -xfs_buf_unlock (mp->m_rtsb_bp); - } - -return error; -} - void xfs_fs_geometry( struct xfs_mount *mp,
fs/xfs/libxfs/xfs_sb.h +0 -1
@@ -15,7 +15,6 @@ struct xfs_perag;extern void xfs_log_sb (struct xfs_trans *tp);extern int xfs_sync_sb (struct xfs_mount *mp,bool wait); -extern int xfs_sync_sb_buf (struct xfs_mount *mp,bool update_rtsb);extern void xfs_sb_mount_common (struct xfs_mount *mp,struct xfs_sb *sbp);void xfs_sb_mount_rextsize (struct xfs_mount *mp,struct xfs_sb *sbp); void xfs_mount_sb_set_rextsize(struct xfs_mount *mp,
fs/xfs/xfs_ioctl.c +40 -0
@@ -1035,6 +1035,46 @@ xfs_ioc_getlabel(return 0 ; } +/* +* Same behavior as xfs_sync_sb, except that it is always synchronous and it +* also writes the superblock buffer to disk sector 0 immediately. +*/ +static int +xfs_sync_sb_buf ( +struct xfs_mount *mp, +bool update_rtsb) +{ +struct xfs_trans *tp; +int error; + + error =xfs_trans_alloc (mp, &M_RES (mp)->tr_sb,0 ,0 ,0 , &tp); +if (error) +return error; + +xfs_log_sb (tp); +if (update_rtsb) +xfs_log_rtsb (tp,xfs_trans_getsb (tp)); +xfs_trans_set_sync (tp); + error =xfs_trans_commit (tp); +if (error) +return error; + +/* Re-acquire and write the sb and rtsb to disk. */ +xfs_buf_lock (mp->m_sb_bp); + error =xfs_bwrite (mp->m_sb_bp); +xfs_buf_unlock (mp->m_sb_bp); +if (error) +return error; + +if (update_rtsb && mp->m_rtsb_bp) { +xfs_buf_lock (mp->m_rtsb_bp); + error =xfs_bwrite (mp->m_rtsb_bp); +xfs_buf_unlock (mp->m_rtsb_bp); + } + +return error; +} + static int xfs_ioc_setlabel( struct file *filp,
Signature · 1 line
2.43.0
Looks good:
Reviewed-by Christoph Hellwig <[email protected]>
Quoted 8 lines · Yun Zhou
xfs_sync_sb_buf()dereferencesmp->m_sb_bpandmp->m_rtsb_bp, which only exist in the kernel's structxfs_mount, not in xfsprogs' libxfs. Keeping it in libxfs is a porting hazard.Its only caller,
xfs_ioc_setlabel(), is kernel-only, so move it there and make it static.[...]
Applied to for-next, thanks!
[1/1] xfs: move xfs_sync_sb_buf() out of libxfs into xfs_ioctl.c
commit: 6654fca702b28b87cd365242498262080b1c223f
Best regards,
Signature · 1 line
Carlos Maiolino <[email protected]>