xfs: Remove wrappers for some semaphores
v2 cover xfs: Remove wrappers for some semaphores
Remove some wrappers that we have in XFS around the read-write semaphore locks.
The goal of cleanup is to remove mrlock_t structure and its mr*() wrapper functions and replace it with native rw_semaphore type and its native calls.
Pavel Reichl (7):
xfs: Add xfs_is_{i,io,mmap}locked functions
xfs: Update checking excl. locks for ilock
xfs: Update checking read or write locks for ilock
xfs: Update checking for iolock
xfs: Update checking for mmaplock
xfs: update excl. lock check for IOLOCK and ILOCK
xfs: Replace mrlock_t by rw_semaphore
fs/xfs/libxfs/xfs_attr.c | 2 +- fs/xfs/libxfs/xfs_attr_remote.c | 2 +- fs/xfs/libxfs/xfs_bmap.c | 22 +++--- fs/xfs/libxfs/xfs_inode_fork.c | 2 +- fs/xfs/libxfs/xfs_rtbitmap.c | 2 +- fs/xfs/libxfs/xfs_trans_inode.c | 6 +- fs/xfs/mrlock.h | 78 ---------------------- fs/xfs/xfs_attr_list.c | 2 +- fs/xfs/xfs_bmap_util.c | 8 +-- fs/xfs/xfs_dquot.c | 4 +- fs/xfs/xfs_file.c | 5 +- fs/xfs/xfs_inode.c | 114 ++++++++++++++++++++------------ fs/xfs/xfs_inode.h | 10 ++- fs/xfs/xfs_inode_item.c | 4 +- fs/xfs/xfs_iops.c | 12 ++-- fs/xfs/xfs_linux.h | 1 - fs/xfs/xfs_qm.c | 12 ++-- fs/xfs/xfs_reflink.c | 2 +- fs/xfs/xfs_rtalloc.c | 4 +- fs/xfs/xfs_super.c | 6 +- fs/xfs/xfs_symlink.c | 2 +- fs/xfs/xfs_trans_dquot.c | 2 +- 22 files changed, 127 insertions(+), 175 deletions(-) delete mode 100644 fs/xfs/mrlock.h
Signature · 1 line
2.24.1
PATCH v2 1/7 xfs: Add xfs_is_{i,io,mmap}locked functions
Add xfs_is_ilocked(), xfs_is_iolocked() and xfs_is_mmaplocked()
--- fs/xfs/xfs_inode.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_inode.h | 3 +++ 2 files changed, 56 insertions(+)
fs/xfs/xfs_inode.c +53 -0
@@ -372,6 +372,59 @@ xfs_isilocked(ASSERT (0 );return 0 ; } + +static inline bool +__xfs_is_ilocked ( +struct rw_semaphore *rwsem, +bool shared, +bool excl) +{ +bool locked = false; + +if (!rwsem_is_locked (rwsem)) +return false; + +if (!debug_locks) +return true; + +if (shared) + locked =lockdep_is_held_type (rwsem,0 ); + +if (excl) + locked |=lockdep_is_held_type (rwsem,1 ); + +return locked; +} + +bool +xfs_is_ilocked ( +struct xfs_inode *ip, +int lock_flags) +{ +return __xfs_is_ilocked (&ip->i_lock.mr_lock, + (lock_flags &XFS_ILOCK_SHARED ), + (lock_flags &XFS_ILOCK_EXCL )); +} + +bool +xfs_is_mmaplocked ( +struct xfs_inode *ip, +int lock_flags) +{ +return __xfs_is_ilocked (&ip->i_mmaplock.mr_lock, + (lock_flags &XFS_MMAPLOCK_SHARED ), + (lock_flags &XFS_MMAPLOCK_EXCL )); +} + +bool +xfs_is_iolocked ( +struct xfs_inode *ip, +int lock_flags) +{ +return __xfs_is_ilocked (&VFS_I (ip)->i_rwsem, + (lock_flags &XFS_IOLOCK_SHARED ), + (lock_flags &XFS_IOLOCK_EXCL )); +}#endif /*
fs/xfs/xfs_inode.h +3 -0
@@ -417,6 +417,9 @@ int xfs_ilock_nowait(xfs_inode_t *, uint);void xfs_iunlock (xfs_inode_t *,uint );void xfs_ilock_demote (xfs_inode_t *,uint );int xfs_isilocked (xfs_inode_t *,uint ); +bool xfs_is_ilocked (struct xfs_inode *,int ); +bool xfs_is_mmaplocked (struct xfs_inode *,int ); +bool xfs_is_iolocked (struct xfs_inode *,int );uint xfs_ilock_data_map_shared (struct xfs_inode *);uint xfs_ilock_attr_map_shared (struct xfs_inode *);
Signature · 1 line
2.24.1
Re: [PATCH v2 1/7] xfs: Add xfs_is_{i,io,mmap}locked functions
Hi Pavel,
Thanks for the patch. Please see inline-comment.
Quoted 35 lines · Pavel Reichl
Add
xfs_is_ilocked(),xfs_is_iolocked()andxfs_is_mmaplocked()Signed-off-by Pavel Reichl <[email protected]>Suggested-by Dave Chinner <[email protected]>--- fs/xfs/xfs_inode.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_inode.h | 3 +++ 2 files changed, 56 insertions(+)fs/xfs/xfs_inode.c +18
-0@@ -372,6 +372,59 @@ xfs_isilocked(ASSERT (0 );return 0 ; } + +static inline bool +__xfs_is_ilocked ( +struct rw_semaphore *rwsem, +bool shared, +bool excl) +{ +bool locked = false; + +if (!rwsem_is_locked (rwsem)) +return false; + +if (!debug_locks) +return true; + +if (shared) + locked =lockdep_is_held_type (rwsem,0 ); +
fs/xfs/xfs_inode.c xfs_isilocked( · line 402
Quoted 10 lines
fs/xfs/xfs_inode.c +10
-0+if (excl) + locked |=lockdep_is_held_type (rwsem,1 ); + +return locked; +} + +bool +xfs_is_ilocked ( +struct xfs_inode *ip, +int lock_flags)
nit:- isn't above lock_flag variable should be uint ? Is there a particular reason that it has int type ?
fs/xfs/xfs_inode.c xfs_isilocked( · line 412
Quoted 10 lines
fs/xfs/xfs_inode.c +10
-0+{ +return __xfs_is_ilocked (&ip->i_lock.mr_lock, + (lock_flags &XFS_ILOCK_SHARED ), + (lock_flags &XFS_ILOCK_EXCL )); +} + +bool +xfs_is_mmaplocked ( +struct xfs_inode *ip, +int lock_flags)
Same here.
fs/xfs/xfs_inode.c xfs_isilocked( · line 422
Quoted 10 lines
fs/xfs/xfs_inode.c +10
-0+{ +return __xfs_is_ilocked (&ip->i_mmaplock.mr_lock, + (lock_flags &XFS_MMAPLOCK_SHARED ), + (lock_flags &XFS_MMAPLOCK_EXCL )); +} + +bool +xfs_is_iolocked ( +struct xfs_inode *ip, +int lock_flags)
Same here.
Quoted 23 lines
fs/xfs/xfs_inode.c +5
-0+{ +return __xfs_is_ilocked (&VFS_I (ip)->i_rwsem, + (lock_flags &XFS_IOLOCK_SHARED ), + (lock_flags &XFS_IOLOCK_EXCL )); +}#endif /* fs/xfs/xfs_inode.h +3
-0@@ -417,6 +417,9 @@ int xfs_ilock_nowait(xfs_inode_t *, uint);void xfs_iunlock (xfs_inode_t *,uint );void xfs_ilock_demote (xfs_inode_t *,uint );int xfs_isilocked (xfs_inode_t *,uint ); +bool xfs_is_ilocked (struct xfs_inode *,int ); +bool xfs_is_mmaplocked (struct xfs_inode *,int ); +bool xfs_is_iolocked (struct xfs_inode *,int );uint xfs_ilock_data_map_shared (struct xfs_inode *);uint xfs_ilock_attr_map_shared (struct xfs_inode *);
Re: [PATCH v2 1/7] xfs: Add xfs_is_{i,io,mmap}locked functions
In reply to Pavel ReichlQuoted 1 line · Pavel Reichl
Add
xfs_is_ilocked(),xfs_is_iolocked()andxfs_is_mmaplocked()
The commit description is supposed to explain "Why?" rather than describe what the code does.
So why are we adding these interfaces?
Quoted 28 lines
Signed-off-by Pavel Reichl <[email protected]>Suggested-by Dave Chinner <[email protected]>--- fs/xfs/xfs_inode.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_inode.h | 3 +++ 2 files changed, 56 insertions(+)fs/xfs/xfs_inode.c +13
-0@@ -372,6 +372,59 @@ xfs_isilocked(ASSERT (0 );return 0 ; } + +static inline bool +__xfs_is_ilocked ( +struct rw_semaphore *rwsem, +bool shared, +bool excl) +{ +bool locked = false; + +if (!rwsem_is_locked (rwsem)) +return false; + +if (!debug_locks)
fs/xfs/xfs_inode.c xfs_isilocked( · line 397
Quoted 10 lines
fs/xfs/xfs_inode.c +10
-0+return true; + +if (shared) + locked =lockdep_is_held_type (rwsem,0 ); + +if (excl) + locked |=lockdep_is_held_type (rwsem,1 ); + +return locked; +}
This needs a comment explaining the reason why it is structured this way. I can see quite clearly what it is doing, but why it is done this way is not immediately apparent from the code.
In a few months, I'm not going to remember the reasons for this code, and if the neither the code nor the commit description explains the reasons why the code is like this, then it's really quite difficult and time consuming to try to discover the reason for the code being this way.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH v2 1/7] xfs: Add xfs_is_{i,io,mmap}locked functions
In reply to Pavel ReichlQuoted 40 lines · Pavel Reichl
Add
xfs_is_ilocked(),xfs_is_iolocked()andxfs_is_mmaplocked()Signed-off-by Pavel Reichl <[email protected]>Suggested-by Dave Chinner <[email protected]>--- fs/xfs/xfs_inode.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_inode.h | 3 +++ 2 files changed, 56 insertions(+)fs/xfs/xfs_inode.c +23
-0@@ -372,6 +372,59 @@ xfs_isilocked(ASSERT (0 );return 0 ; } + +static inline bool +__xfs_is_ilocked ( +struct rw_semaphore *rwsem, +bool shared, +bool excl) +{ +bool locked = false; + +if (!rwsem_is_locked (rwsem)) +return false; + +if (!debug_locks) +return true; + +if (shared) + locked =lockdep_is_held_type (rwsem,0 ); + +if (excl) + locked |=lockdep_is_held_type (rwsem,1 ); + +return locked; +}
fs/xfs/xfs_inode.c xfs_isilocked( · line 407
Quoted 10 lines
fs/xfs/xfs_inode.c +10
-0+ +bool +xfs_is_ilocked ( +struct xfs_inode *ip, +int lock_flags) +{ +return __xfs_is_ilocked (&ip->i_lock.mr_lock, + (lock_flags &XFS_ILOCK_SHARED ), + (lock_flags &XFS_ILOCK_EXCL )); +}
Apologies for not following or chiming in sooner on the prior discussion.
It seems a little odd that we must specify the lock type to test to each of these 3 functions which are already named after a specific lock type.
i.e.:
xfs_is_mmaplocked(XFS_MMAPLOCK_EXCL);
seems a little redundant, but more problematic:
xfs_is_mmaplocked(XFS_ILOCK_SHARED);
would be accepted and silently return false. I think that at least an ASSERT() in each of the 3 functions to be sure we didn't pass in nonsense flags would be wise.
-Eric
Re: [PATCH v2 1/7] xfs: Add xfs_is_{i,io,mmap}locked functions
In reply to Pavel Reichlfs/xfs/xfs_inode.c xfs_isilocked( · line 380
Quoted 5 lines
fs/xfs/xfs_inode.c +5
-0+static inline bool +__xfs_is_ilocked ( +struct rw_semaphore *rwsem, +bool shared, +bool excl)
This calling conventions seems odd. In other places like lockdep we just have a bool excl. This means we might get a false positive when the lock is held exclusive but only shared is asserted, but given that the low-level helpers can't give better information that isn't going to hurt.
Also I'd name this function xfs_rwsem_is_locked, as there is nothing inode specific here.
I also agree that this function needs good comments explaining the rationale.
Quoted 20 lines
fs/xfs/xfs_inode.c +20
-0+bool +xfs_is_ilocked ( +struct xfs_inode *ip, +int lock_flags) +{ +return __xfs_is_ilocked (&ip->i_lock.mr_lock, + (lock_flags &XFS_ILOCK_SHARED ), + (lock_flags &XFS_ILOCK_EXCL )); +} + +bool +xfs_is_mmaplocked ( +struct xfs_inode *ip, +int lock_flags) +{ +return __xfs_is_ilocked (&ip->i_mmaplock.mr_lock, + (lock_flags &XFS_MMAPLOCK_SHARED ), + (lock_flags &XFS_MMAPLOCK_EXCL )); +} +
fs/xfs/xfs_inode.c xfs_isilocked( · line 428
Quoted 10 lines
fs/xfs/xfs_inode.c +9
-0+bool +xfs_is_iolocked ( +struct xfs_inode *ip, +int lock_flags) +{ +return __xfs_is_ilocked (&VFS_I (ip)->i_rwsem, + (lock_flags &XFS_IOLOCK_SHARED ), + (lock_flags &XFS_IOLOCK_EXCL )); +}#endif
What is the benefit of these helpers? xfs_isilocked can just call __xfs_is_ilocked / xfs_rwsem_is_locked directly.
PATCH v2 2/7 xfs: Update checking excl. locks for ilock
In reply to Pavel Reichl--- fs/xfs/libxfs/xfs_attr_remote.c | 2 +- fs/xfs/libxfs/xfs_bmap.c | 10 +++++----- fs/xfs/libxfs/xfs_rtbitmap.c | 2 +- fs/xfs/libxfs/xfs_trans_inode.c | 6 +++--- fs/xfs/xfs_dquot.c | 4 ++-- fs/xfs/xfs_inode.c | 4 ++-- fs/xfs/xfs_inode_item.c | 4 ++-- fs/xfs/xfs_iops.c | 4 ++-- fs/xfs/xfs_qm.c | 10 +++++----- fs/xfs/xfs_reflink.c | 2 +- fs/xfs/xfs_rtalloc.c | 4 ++-- fs/xfs/xfs_trans_dquot.c | 2 +- 12 files changed, 27 insertions(+), 27 deletions(-)
fs/xfs/libxfs/xfs_attr_remote.c +1 -1
@@ -577,7 +577,7 @@ xfs_attr_rmtval_stale(struct xfs_mount *mp = ip->i_mount;struct xfs_buf *bp; -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_EXCL ));if (XFS_IS_CORRUPT (mp, map->br_startblock ==DELAYSTARTBLOCK ) ||XFS_IS_CORRUPT (mp, map->br_startblock ==HOLESTARTBLOCK ))
fs/xfs/libxfs/xfs_bmap.c +5 -5
@@ -1238,7 +1238,7 @@ xfs_iread_extents(struct xfs_btree_cur *cur;int error; -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_EXCL )); if (XFS_IS_CORRUPT(mp, XFS_IFORK_FORMAT(ip, whichfork) !=
@@ -4402,7 +4402,7 @@ xfs_bmapi_write(ASSERT (tp !=NULL );ASSERT (len >0 );ASSERT (XFS_IFORK_FORMAT (ip, whichfork) !=XFS_DINODE_FMT_LOCAL ); -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_EXCL ));ASSERT (!(flags &XFS_BMAPI_REMAP ));/* zeroing is for currently only for data extents, not metadata */
@@ -4678,7 +4678,7 @@ xfs_bmapi_remap( ifp =XFS_IFORK_PTR (ip, whichfork);ASSERT (len >0 );ASSERT (len <= (xfs_filblks_t )MAXEXTLEN ); -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_EXCL ));ASSERT (!(flags & ~(XFS_BMAPI_ATTRFORK |XFS_BMAPI_PREALLOC |XFS_BMAPI_NORMAP ))); ASSERT((flags & (XFS_BMAPI_ATTRFORK | XFS_BMAPI_PREALLOC)) !=
@@ -5329,7 +5329,7 @@ __xfs_bunmapi(if (XFS_FORCED_SHUTDOWN (mp))return -EIO ; -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_EXCL ));ASSERT (len >0 );ASSERT (nexts >=0 );
@@ -5700,7 +5700,7 @@ xfs_bmse_merge( blockcount = left->br_blockcount + got->br_blockcount;ASSERT (xfs_isilocked (ip,XFS_IOLOCK_EXCL )); -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_EXCL ));ASSERT (xfs_bmse_can_merge (left, got, shift)); new = *left;
fs/xfs/libxfs/xfs_rtbitmap.c +1 -1
@@ -974,7 +974,7 @@ xfs_rtfree_extent( mp = tp->t_mountp;ASSERT (mp->m_rbmip->i_itemp !=NULL ); -ASSERT (xfs_isilocked (mp->m_rbmip,XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (mp->m_rbmip,XFS_ILOCK_EXCL )); error =xfs_rtcheck_alloc_range (mp, tp, bno, len);if (error)
fs/xfs/libxfs/xfs_trans_inode.c +3 -3
@@ -29,7 +29,7 @@ xfs_trans_ijoin( {xfs_inode_log_item_t *iip; -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_EXCL ));if (ip->i_itemp ==NULL )xfs_inode_item_init (ip, ip->i_mount); iip = ip->i_itemp;
@@ -58,7 +58,7 @@ xfs_trans_ichgtime(struct timespec64 tv;ASSERT (tp); -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_EXCL )); tv =current_time (inode);
@@ -88,7 +88,7 @@ xfs_trans_log_inode(struct inode *inode =VFS_I (ip);ASSERT (ip->i_itemp !=NULL ); -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_EXCL ));/* * Don't bother with i_lock for the I_DIRTY_TIME check here, as races
fs/xfs/xfs_dquot.c +2 -2
@@ -862,7 +862,7 @@ xfs_qm_dqget_inode(if (error)return error; -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_EXCL ));ASSERT (xfs_inode_dquot (ip, type) ==NULL ); id =xfs_qm_id_for_quotatype (ip, type);
@@ -919,7 +919,7 @@ xfs_qm_dqget_inode( } dqret: -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_EXCL ));trace_xfs_dqget_miss (dqp); *O_dqpp = dqp;return 0 ;
fs/xfs/xfs_inode.c +2 -2
@@ -1574,7 +1574,7 @@ xfs_itruncate_extents_flags(xfs_filblks_t unmap_len;int error =0 ; -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_EXCL ));ASSERT (!atomic_read (&VFS_I (ip)->i_count) ||xfs_isilocked (ip,XFS_IOLOCK_EXCL ));ASSERT (new_size <=XFS_ISIZE (ip));
@@ -2805,7 +2805,7 @@ xfs_ifree(int error;struct xfs_icluster xic = {0 }; -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_EXCL ));ASSERT (VFS_I (ip)->i_nlink ==0 );ASSERT (ip->i_d.di_nextents ==0 );ASSERT (ip->i_d.di_anextents ==0 );
fs/xfs/xfs_inode_item.c +2 -2
@@ -440,7 +440,7 @@ xfs_inode_item_pin( {struct xfs_inode *ip =INODE_ITEM (lip)->ili_inode; -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_EXCL ));trace_xfs_inode_pin (ip, _RET_IP_);atomic_inc (&ip->i_pincount);
@@ -574,7 +574,7 @@ xfs_inode_item_release(unsigned short lock_flags;ASSERT (ip->i_itemp !=NULL ); -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_EXCL )); lock_flags = iip->ili_lock_flags; iip->ili_lock_flags =0 ;
fs/xfs/xfs_iops.c +2 -2
@@ -598,7 +598,7 @@ xfs_setattr_mode(struct inode *inode =VFS_I (ip);umode_t mode = iattr->ia_mode; -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_EXCL )); inode->i_mode &=S_IFMT ; inode->i_mode |= mode & ~S_IFMT ;
@@ -611,7 +611,7 @@ xfs_setattr_time( {struct inode *inode =VFS_I (ip); -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_EXCL ));if (iattr->ia_valid &ATTR_ATIME ) inode->i_atime = iattr->ia_atime;
fs/xfs/xfs_qm.c +5 -5
@@ -253,7 +253,7 @@ xfs_qm_dqattach_one(struct xfs_dquot *dqp;int error; -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_EXCL )); error =0 ;/*
@@ -323,7 +323,7 @@ xfs_qm_dqattach_locked(if (!xfs_qm_need_dqattach (ip))return 0 ; -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_EXCL ));if (XFS_IS_UQUOTA_ON (mp) && !ip->i_udquot) { error = xfs_qm_dqattach_one(ip, ip->i_d.di_uid, XFS_DQ_USER,
@@ -354,7 +354,7 @@ xfs_qm_dqattach_locked(* Don't worry about the dquots that we may have attached before any * error - they'll get detached later if it has not already been done. */ -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_EXCL ));return error; }
@@ -1754,7 +1754,7 @@ xfs_qm_vop_chown( XFS_TRANS_DQ_RTBCOUNT :XFS_TRANS_DQ_BCOUNT ; -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_EXCL ));ASSERT (XFS_IS_QUOTA_RUNNING (ip->i_mount));/* old dquot */
@@ -1915,7 +1915,7 @@ xfs_qm_vop_create_dqattach(if (!XFS_IS_QUOTA_RUNNING (mp) || !XFS_IS_QUOTA_ON (mp))return ; -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_EXCL ));ASSERT (XFS_IS_QUOTA_RUNNING (mp));if (udqp &&XFS_IS_UQUOTA_ON (mp)) {
fs/xfs/xfs_reflink.c +1 -1
@@ -359,7 +359,7 @@ xfs_reflink_allocate_cow(xfs_filblks_t resaligned;xfs_extlen_t resblks =0 ; -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_EXCL ));if (!ip->i_cowfp) {ASSERT (!xfs_is_reflink_inode (ip));xfs_ifork_init_cow (ip);
fs/xfs/xfs_rtalloc.c +2 -2
@@ -1121,7 +1121,7 @@ xfs_rtallocate_extent(xfs_fsblock_t sb;/* summary file block number */ xfs_buf_t *sumbp;/* summary file block buffer */ -ASSERT (xfs_isilocked (mp->m_rbmip,XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (mp->m_rbmip,XFS_ILOCK_EXCL ));ASSERT (minlen >0 && minlen <= maxlen);/*
@@ -1278,7 +1278,7 @@ xfs_rtpick_extent(uint64_t seq;/* sequence number of file creation */ uint64_t *seqp;/* pointer to seqno in inode */ -ASSERT (xfs_isilocked (mp->m_rbmip,XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (mp->m_rbmip,XFS_ILOCK_EXCL )); seqp = (uint64_t *)&VFS_I (mp->m_rbmip)->i_atime;if (!(mp->m_rbmip->i_d.di_flags &XFS_DIFLAG_NEWRTBM )) {
fs/xfs/xfs_trans_dquot.c +1 -1
@@ -808,7 +808,7 @@ xfs_trans_reserve_quota_nblks(ASSERT (!xfs_is_quota_inode (&mp->m_sb, ip->i_ino)); -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_EXCL ));ASSERT ((flags & ~(XFS_QMOPT_FORCE_RES |XFS_QMOPT_ENOSPC )) ==XFS_TRANS_DQ_RES_RTBLKS || (flags & ~(XFS_QMOPT_FORCE_RES | XFS_QMOPT_ENOSPC)) ==
Signature · 1 line
2.24.1
Re: [PATCH v2 2/7] xfs: Update checking excl. locks for ilock
Quoted 16 lines · Pavel Reichl
Signed-off-by Pavel Reichl <[email protected]>Suggested-by Dave Chinner <[email protected]>--- fs/xfs/libxfs/xfs_attr_remote.c | 2 +- fs/xfs/libxfs/xfs_bmap.c | 10 +++++----- fs/xfs/libxfs/xfs_rtbitmap.c | 2 +- fs/xfs/libxfs/xfs_trans_inode.c | 6 +++--- fs/xfs/xfs_dquot.c | 4 ++-- fs/xfs/xfs_inode.c | 4 ++-- fs/xfs/xfs_inode_item.c | 4 ++-- fs/xfs/xfs_iops.c | 4 ++-- fs/xfs/xfs_qm.c | 10 +++++----- fs/xfs/xfs_reflink.c | 2 +- fs/xfs/xfs_rtalloc.c | 4 ++-- fs/xfs/xfs_trans_dquot.c | 2 +- 12 files changed, 27 insertions(+), 27 deletions(-)
Looks fine, though you could combine this with the next patch.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH v2 2/7] xfs: Update checking excl. locks for ilock
In reply to Pavel ReichlReview
Quoted 2 lines
(quoted diff) +1
-1- ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL));
I think this is a very bad interface. Either we keep our good old xfs_isilocked that just operates on the inode and lock flags, or we use something that gets the actual lock passed. But an interface that encodes the lock in both the function called and the flags, and one that doesn't follow neither the XFS lock flags conventions nor the core kernel convention is just not very useful.
Re: [PATCH v2 2/7] xfs: Update checking excl. locks for ilock
Quoted 9 lines · Christoph Hellwig
Review
Quoted 2 lines
(quoted diff) +1
-1- ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL));I think this is a very bad interface. Either we keep our good old
xfs_isilockedthat just operates on the inode and lock flags, or we use something that gets the actual lock passed. But an interface that encodes the lock in both the function called and the flags, and one that doesn't follow neither the XFS lock flags conventions nor the core kernel convention is just not very useful.
I think this came out of Dave's suggestion on the previous patchset, but I agree with you Chrisoph. Even if there is a future reason to split it out into a function for each type, I don't see a reason to do it now, and this interface is awkward.
I'd prefer to keep xfs_isilocked() with the current calling convention and just change its internals to use lockdep. Dave spotted a bug in the current implementation, but I think that can be fixed.
Splitting out the 3 lock testing functions seems to me like complexity creep that doesn't need to be in this series.
Dave, thoughts?
-Eric
Re: [PATCH v2 2/7] xfs: Update checking excl. locks for ilock
Quoted 16 lines · Eric Sandeen
Quoted 9 lines · Christoph Hellwig
Review
Quoted 2 lines
(quoted diff) +1
-1- ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL));I think this is a very bad interface. Either we keep our good old
xfs_isilockedthat just operates on the inode and lock flags, or we use something that gets the actual lock passed. But an interface that encodes the lock in both the function called and the flags, and one that doesn't follow neither the XFS lock flags conventions nor the core kernel convention is just not very useful.I think this came out of Dave's suggestion on the previous patchset, but I agree with you Chrisoph. Even if there is a future reason to split it out into a function for each type, I don't see a reason to do it now, and this interface is awkward.
Quoted 8 lines
I'd prefer to keep
xfs_isilocked()with the current calling convention and just change its internals to use lockdep. Dave spotted a bug in the current implementation, but I think that can be fixed.Splitting out the 3 lock testing functions seems to me like complexity creep that doesn't need to be in this series.
Dave, thoughts?
All I care about is that we get rid of the mrlock_t. I'm not interested in bikeshedding the details to death. I've put my 2c worth in, if you don't like it, then that's fine and I'm not going to get upset about that.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH v2 2/7] xfs: Update checking excl. locks for ilock
Quoted 24 lines · Dave Chinner
Quoted 23 lines · Eric Sandeen
Quoted 9 lines · Christoph Hellwig
Review
Quoted 2 lines
(quoted diff) +1
-1- ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL));I think this is a very bad interface. Either we keep our good old
xfs_isilockedthat just operates on the inode and lock flags, or we use something that gets the actual lock passed. But an interface that encodes the lock in both the function called and the flags, and one that doesn't follow neither the XFS lock flags conventions nor the core kernel convention is just not very useful.I think this came out of Dave's suggestion on the previous patchset, but I agree with you Chrisoph. Even if there is a future reason to split it out into a function for each type, I don't see a reason to do it now, and this interface is awkward.
I'd prefer to keep
xfs_isilocked()with the current calling convention and just change its internals to use lockdep. Dave spotted a bug in the current implementation, but I think that can be fixed.Splitting out the 3 lock testing functions seems to me like complexity creep that doesn't need to be in this series.
Quoted 6 lines
Quoted 1 line
Dave, thoughts?
All I care about is that we get rid of the
mrlock_t. I'm not interested in bikeshedding the details to death. I've put my 2c worth in, if you don't like it, then that's fine and I'm not going to get upset about that.
In the short term I'd suggest something like this. It keeps the helper, but we don't have to change the callsites, and breaking out separate types etc can be done after the mrlock removal patchset is done - in a separate series if/when needed.
static inline bool
__xfs_rwsem_islocked(
struct rw_semaphore *rwsem,
bool shared,
bool excl)
{
bool locked = false;
if (!rwsem_is_locked(rwsem))
return false;
if (!debug_locks)
return true;
if (shared)
locked = lockdep_is_held_type(rwsem, 0);
if (excl)
locked |= lockdep_is_held_type(rwsem, 1);
return locked;
}bool
xfs_isilocked(
struct xfs_inode *ip,
uint lock_flags)
{
if (lock_flags & (XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)) {
return __xfs_rwsem_islocked(&ip->i_lock.mr_lock,
(lock_flags & XFS_ILOCK_SHARED),
(lock_flags & XFS_ILOCK_EXCL));
}
if (lock_flags & (XFS_MMAPLOCK_EXCL|XFS_MMAPLOCK_SHARED)) {
return __xfs_rwsem_islocked(&ip->i_mmlock.mr_lock,
(lock_flags & XFS_MMAPLOCK_SHARED),
(lock_flags & XFS_MMAPLOCK_EXCL));
}
if (lock_flags & (XFS_IOLOCK_EXCL|XFS_IOLOCK_SHARED)) {
return __xfs_rwsem_islocked(&VFS_I(ip)->i_rwsem,
(lock_flags & XFS_IOLOCK_SHARED),
(lock_flags & XFS_IOLOCK_EXCL));
}
}That still has the problem/bug with the existing
ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL));
callsite since it doesn't actually test both types but again that is a separate bugfix - it could be changed to accumulate a true/false state for all the flags in the lock_flags argument in another bugfix patch.
-Eric
PATCH v2 3/7 xfs: Update checking read or write locks for ilock
In reply to Pavel Reichl--- fs/xfs/libxfs/xfs_attr.c | 2 +- fs/xfs/libxfs/xfs_bmap.c | 2 +- fs/xfs/libxfs/xfs_inode_fork.c | 2 +- fs/xfs/xfs_attr_list.c | 2 +- fs/xfs/xfs_inode.c | 6 +++--- fs/xfs/xfs_qm.c | 2 +- fs/xfs/xfs_symlink.c | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-)
fs/xfs/libxfs/xfs_attr.c +1 -1
@@ -107,7 +107,7 @@ xfs_attr_get_ilocked(struct xfs_inode *ip, struct xfs_da_args *args) { - ASSERT(xfs_isilocked(ip, XFS_ILOCK_SHARED | XFS_ILOCK_EXCL)); + ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_SHARED | XFS_ILOCK_EXCL));if (!xfs_inode_hasattr (ip))return -ENOATTR ;
fs/xfs/libxfs/xfs_bmap.c +1 -1
@@ -3906,7 +3906,7 @@ xfs_bmapi_read(ASSERT (*nmap >=1 );ASSERT (!(flags & ~(XFS_BMAPI_ATTRFORK |XFS_BMAPI_ENTIRE |XFS_BMAPI_COWFORK ))); -ASSERT (xfs_isilocked (ip,XFS_ILOCK_SHARED |XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_SHARED |XFS_ILOCK_EXCL ));if (XFS_IS_CORRUPT (mp, !xfs_ifork_has_extents (ip, whichfork)) ||XFS_TEST_ERROR (false, mp,XFS_ERRTAG_BMAPIFORMAT )) {
fs/xfs/libxfs/xfs_inode_fork.c +1 -1
@@ -560,7 +560,7 @@ xfs_iextents_copy(struct xfs_bmbt_irec rec;int64_t copied =0 ; -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL |XFS_ILOCK_SHARED )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_SHARED |XFS_ILOCK_EXCL ));ASSERT (ifp->if_bytes >0 );for_each_xfs_iext (ifp, &icur, &rec) {
fs/xfs/xfs_attr_list.c +1 -1
@@ -511,7 +511,7 @@ xfs_attr_list_int_ilocked( {struct xfs_inode *dp = context->dp; -ASSERT (xfs_isilocked (dp,XFS_ILOCK_SHARED |XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (dp,XFS_ILOCK_SHARED |XFS_ILOCK_EXCL ));/* * Decide on what work routines to call based on the inode size.
fs/xfs/xfs_inode.c +3 -3
@@ -2859,7 +2859,7 @@ static voidxfs_iunpin ( struct xfs_inode *ip) { -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL |XFS_ILOCK_SHARED )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_SHARED |XFS_ILOCK_EXCL ));trace_xfs_inode_unpin_nowait (ip, _RET_IP_);
@@ -3723,7 +3723,7 @@ xfs_iflush(XFS_STATS_INC (mp, xs_iflush_count); -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL |XFS_ILOCK_SHARED )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_SHARED |XFS_ILOCK_EXCL ));ASSERT (xfs_isiflocked (ip));ASSERT (ip->i_d.di_format !=XFS_DINODE_FMT_BTREE || ip->i_d.di_nextents >XFS_IFORK_MAXEXT (ip,XFS_DATA_FORK ));
@@ -3855,7 +3855,7 @@ xfs_iflush_int(struct xfs_dinode *dip;struct xfs_mount *mp = ip->i_mount; -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL |XFS_ILOCK_SHARED )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_SHARED |XFS_ILOCK_EXCL ));ASSERT (xfs_isiflocked (ip));ASSERT (ip->i_d.di_format !=XFS_DINODE_FMT_BTREE || ip->i_d.di_nextents >XFS_IFORK_MAXEXT (ip,XFS_DATA_FORK ));
fs/xfs/xfs_qm.c +1 -1
@@ -1802,7 +1802,7 @@ xfs_qm_vop_chown_reserve(int error; -ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL |XFS_ILOCK_SHARED )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_SHARED |XFS_ILOCK_EXCL ));ASSERT (XFS_IS_QUOTA_RUNNING (mp)); delblks = ip->i_delayed_blks;
fs/xfs/xfs_symlink.c +1 -1
@@ -41,7 +41,7 @@ xfs_readlink_bmap_ilocked(int fsblocks =0 ;int offset; -ASSERT (xfs_isilocked (ip,XFS_ILOCK_SHARED |XFS_ILOCK_EXCL )); +ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_SHARED |XFS_ILOCK_EXCL )); fsblocks =xfs_symlink_blocks (mp, pathlen); error =xfs_bmapi_read (ip,0 , fsblocks, mval, &nmaps,0 );
Signature · 1 line
2.24.1
Re: [PATCH v2 3/7] xfs: Update checking read or write locks for ilock
Quoted 2 lines · Pavel Reichl
Signed-off-by Pavel Reichl <[email protected]>Suggested-by Dave Chinner <[email protected]>
BTW, for these aPI conversions, you don't really need a suggested-by tag on them. The first patch taht introduces the API, yes, but the mechanical conversions don't really need it.
Otherwise, looks fine.
Signature · 2 lines
Dave Chinner [email protected]
PATCH v2 4/7 xfs: Update checking for iolock
In reply to Pavel Reichl--- fs/xfs/libxfs/xfs_bmap.c | 4 ++-- fs/xfs/xfs_bmap_util.c | 4 ++-- fs/xfs/xfs_file.c | 3 ++- fs/xfs/xfs_inode.c | 2 +- fs/xfs/xfs_iops.c | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-)
fs/xfs/libxfs/xfs_bmap.c +2 -2
@@ -5699,7 +5699,7 @@ xfs_bmse_merge( blockcount = left->br_blockcount + got->br_blockcount; -ASSERT (xfs_isilocked (ip,XFS_IOLOCK_EXCL )); +ASSERT (xfs_is_iolocked (ip,XFS_IOLOCK_EXCL ));ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_EXCL ));ASSERT (xfs_bmse_can_merge (left, got, shift));
@@ -5904,7 +5904,7 @@ xfs_bmap_can_insert_extents(int is_empty;int error =0 ; -ASSERT (xfs_isilocked (ip,XFS_IOLOCK_EXCL )); +ASSERT (xfs_is_iolocked (ip,XFS_IOLOCK_EXCL ));if (XFS_FORCED_SHUTDOWN (ip->i_mount))return -EIO ;
fs/xfs/xfs_bmap_util.c +2 -2
@@ -1065,7 +1065,7 @@ xfs_collapse_file_space(uint resblks =XFS_DIOSTRAT_SPACE_RES (mp,0 );bool done = false; -ASSERT (xfs_isilocked (ip,XFS_IOLOCK_EXCL )); +ASSERT (xfs_is_iolocked (ip,XFS_IOLOCK_EXCL ));ASSERT (xfs_isilocked (ip,XFS_MMAPLOCK_EXCL ));trace_xfs_collapse_file_space (ip);
@@ -1133,7 +1133,7 @@ xfs_insert_file_space(xfs_fileoff_t shift_fsb =XFS_B_TO_FSB (mp, len);bool done = false; -ASSERT (xfs_isilocked (ip,XFS_IOLOCK_EXCL )); +ASSERT (xfs_is_iolocked (ip,XFS_IOLOCK_EXCL ));ASSERT (xfs_isilocked (ip,XFS_MMAPLOCK_EXCL ));trace_xfs_insert_file_space (ip);
fs/xfs/xfs_file.c +2 -1
@@ -770,7 +770,8 @@ xfs_break_layouts(bool retry;int error; -ASSERT (xfs_isilocked (XFS_I (inode),XFS_IOLOCK_SHARED |XFS_IOLOCK_EXCL )); +ASSERT (xfs_is_iolocked (XFS_I (inode), +XFS_IOLOCK_SHARED |XFS_IOLOCK_EXCL )); do { retry = false;
fs/xfs/xfs_inode.c +1 -1
@@ -1576,7 +1576,7 @@ xfs_itruncate_extents_flags(ASSERT (xfs_is_ilocked (ip,XFS_ILOCK_EXCL ));ASSERT (!atomic_read (&VFS_I (ip)->i_count) || -xfs_isilocked (ip,XFS_IOLOCK_EXCL )); +xfs_is_iolocked (ip,XFS_IOLOCK_EXCL ));ASSERT (new_size <=XFS_ISIZE (ip));ASSERT (tp->t_flags &XFS_TRANS_PERM_LOG_RES );ASSERT (ip->i_itemp !=NULL );
fs/xfs/xfs_iops.c +1 -1
@@ -865,7 +865,7 @@ xfs_setattr_size(uint lock_flags =0 ;bool did_zeroing = false; -ASSERT (xfs_isilocked (ip,XFS_IOLOCK_EXCL )); +ASSERT (xfs_is_iolocked (ip,XFS_IOLOCK_EXCL ));ASSERT (xfs_isilocked (ip,XFS_MMAPLOCK_EXCL ));ASSERT (S_ISREG (inode->i_mode)); ASSERT((iattr->ia_valid & (ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_ATIME_SET|
Signature · 1 line
2.24.1
Re: [PATCH v2 4/7] xfs: Update checking for iolock
Quoted 9 lines · Pavel Reichl
Signed-off-by Pavel Reichl <[email protected]>Suggested-by Dave Chinner <[email protected]>--- fs/xfs/libxfs/xfs_bmap.c | 4 ++-- fs/xfs/xfs_bmap_util.c | 4 ++-- fs/xfs/xfs_file.c | 3 ++- fs/xfs/xfs_inode.c | 2 +- fs/xfs/xfs_iops.c | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-)
....
fs/xfs/xfs_file.c xfs_break_layouts( · line 774
Quoted 11 lines
fs/xfs/xfs_file.c +2
-1@@ -770,7 +770,8 @@ xfs_break_layouts(bool retry;int error; -ASSERT (xfs_isilocked (XFS_I (inode),XFS_IOLOCK_SHARED |XFS_IOLOCK_EXCL )); +ASSERT (xfs_is_iolocked (XFS_I (inode), +XFS_IOLOCK_SHARED |XFS_IOLOCK_EXCL ));
Whitespace: XFS_IOLOCK_SHARED | XFS_IOLOCK_EXCL
Otherwise looks ok.
Signature · 2 lines
Dave Chinner [email protected]
PATCH v2 5/7 xfs: Update checking for mmaplock
In reply to Pavel Reichl--- fs/xfs/xfs_bmap_util.c | 4 ++-- fs/xfs/xfs_file.c | 2 +- fs/xfs/xfs_iops.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
fs/xfs/xfs_bmap_util.c +2 -2
@@ -1066,7 +1066,7 @@ xfs_collapse_file_space(bool done = false;ASSERT (xfs_is_iolocked (ip,XFS_IOLOCK_EXCL )); -ASSERT (xfs_isilocked (ip,XFS_MMAPLOCK_EXCL )); +ASSERT (xfs_is_mmaplocked (ip,XFS_MMAPLOCK_EXCL ));trace_xfs_collapse_file_space (ip);
@@ -1134,7 +1134,7 @@ xfs_insert_file_space(bool done = false;ASSERT (xfs_is_iolocked (ip,XFS_IOLOCK_EXCL )); -ASSERT (xfs_isilocked (ip,XFS_MMAPLOCK_EXCL )); +ASSERT (xfs_is_mmaplocked (ip,XFS_MMAPLOCK_EXCL ));trace_xfs_insert_file_space (ip);
fs/xfs/xfs_file.c +1 -1
@@ -749,7 +749,7 @@ xfs_break_dax_layouts( {struct page *page; -ASSERT (xfs_isilocked (XFS_I (inode),XFS_MMAPLOCK_EXCL )); +ASSERT (xfs_is_mmaplocked (XFS_I (inode),XFS_MMAPLOCK_EXCL )); page =dax_layout_busy_page (inode->i_mapping);if (!page)
fs/xfs/xfs_iops.c +1 -1
@@ -866,7 +866,7 @@ xfs_setattr_size(bool did_zeroing = false;ASSERT (xfs_is_iolocked (ip,XFS_IOLOCK_EXCL )); -ASSERT (xfs_isilocked (ip,XFS_MMAPLOCK_EXCL )); +ASSERT (xfs_is_mmaplocked (ip,XFS_MMAPLOCK_EXCL ));ASSERT (S_ISREG (inode->i_mode));ASSERT ((iattr->ia_valid & (ATTR_UID |ATTR_GID |ATTR_ATIME |ATTR_ATIME_SET |ATTR_MTIME_SET |ATTR_KILL_PRIV |ATTR_TIMES_SET )) ==0 );
Signature · 1 line
2.24.1
Re: [PATCH v2 5/7] xfs: Update checking for mmaplock
Quoted 7 lines · Pavel Reichl
Signed-off-by Pavel Reichl <[email protected]>Suggested-by Dave Chinner <[email protected]>--- fs/xfs/xfs_bmap_util.c | 4 ++-- fs/xfs/xfs_file.c | 2 +- fs/xfs/xfs_iops.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
looks fine.
Signature · 2 lines
Dave Chinner [email protected]
PATCH v2 6/7 xfs: update excl. lock check for IOLOCK and ILOCK
In reply to Pavel Reichl--- fs/xfs/libxfs/xfs_bmap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/xfs/libxfs/xfs_bmap.c +4 -2
@@ -5829,7 +5829,8 @@ xfs_bmap_collapse_extents(if (XFS_FORCED_SHUTDOWN (mp))return -EIO ; -ASSERT (xfs_isilocked (ip,XFS_IOLOCK_EXCL |XFS_ILOCK_EXCL )); +ASSERT (xfs_is_iolocked (ip,XFS_IOLOCK_EXCL ) || +xfs_is_ilocked (ip,XFS_ILOCK_EXCL ));if (!(ifp->if_flags &XFS_IFEXTENTS )) { error =xfs_iread_extents (tp, ip, whichfork);
@@ -5946,7 +5947,8 @@ xfs_bmap_insert_extents(if (XFS_FORCED_SHUTDOWN (mp))return -EIO ; -ASSERT (xfs_isilocked (ip,XFS_IOLOCK_EXCL |XFS_ILOCK_EXCL )); +ASSERT (xfs_is_iolocked (ip,XFS_IOLOCK_EXCL ) || +xfs_is_ilocked (ip,XFS_ILOCK_EXCL ));if (!(ifp->if_flags &XFS_IFEXTENTS )) { error =xfs_iread_extents (tp, ip, whichfork);
Signature · 1 line
2.24.1
Re: [PATCH v2 6/7] xfs: update excl. lock check for IOLOCK and ILOCK
Quoted 11 lines · Pavel Reichl
Signed-off-by Pavel Reichl <[email protected]>Suggested-by Dave Chinner <[email protected]>--- fs/xfs/libxfs/xfs_bmap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)fs/xfs/libxfs/xfs_bmap.c +0
-0
fs/xfs/libxfs/xfs_bmap.c xfs_bmap_collapse_extents( · line 5833
Quoted 6 lines
fs/xfs/libxfs/xfs_bmap.c +2
-1@@ -5829,7 +5829,8 @@ xfs_bmap_collapse_extents(if (XFS_FORCED_SHUTDOWN (mp))return -EIO ; -ASSERT (xfs_isilocked (ip,XFS_IOLOCK_EXCL |XFS_ILOCK_EXCL )); +ASSERT (xfs_is_iolocked (ip,XFS_IOLOCK_EXCL ) || +xfs_is_ilocked (ip,XFS_ILOCK_EXCL ));
Hmmm. I think this is incorrect - a bug in the original code in that xfs_isilocked() will only check one lock type and so this never worked as intended.
That is, we should have both the IOLOCK and the ILOCK held here. The IOLOCK is taken by the high level xfs_file_fallocate() code to lock out IO, while ILOCK is taken cwinside the transaction to make the metadata changes atomic.
Hence I think this should actually end up as:
ASSERT(xfs_is_iolocked(ip, XFS_IOLOCK_EXCL)); ASSERT(xfs_is_ilocked(ip, XFS_ILOCK_EXCL));
fs/xfs/libxfs/xfs_bmap.c xfs_bmap_insert_extents( · line 5951
Quoted 10 lines
fs/xfs/libxfs/xfs_bmap.c +2
-1if (!(ifp->if_flags &XFS_IFEXTENTS )) { error =xfs_iread_extents (tp, ip, whichfork);@@ -5946,7 +5947,8 @@ xfs_bmap_insert_extents(if (XFS_FORCED_SHUTDOWN (mp))return -EIO ; -ASSERT (xfs_isilocked (ip,XFS_IOLOCK_EXCL |XFS_ILOCK_EXCL )); +ASSERT (xfs_is_iolocked (ip,XFS_IOLOCK_EXCL ) || +xfs_is_ilocked (ip,XFS_ILOCK_EXCL ));
Same here.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
PATCH v2 7/7 xfs: Replace mrlock_t by rw_semaphore
In reply to Pavel ReichlRemove mrlock_t as it does not provide any extra value over rw_semaphores. Make i_lock and i_mmaplock native rw_semaphores and replace mr*() functions with native rwsem calls.
--- fs/xfs/mrlock.h | 78 ---------------------------------------------- fs/xfs/xfs_inode.c | 65 +++++++++++--------------------------- fs/xfs/xfs_inode.h | 7 +++-- fs/xfs/xfs_iops.c | 4 +-- fs/xfs/xfs_linux.h | 1 - fs/xfs/xfs_super.c | 6 ++-- 6 files changed, 27 insertions(+), 134 deletions(-) delete mode 100644 fs/xfs/mrlock.h
fs/xfs/mrlock.h deleted +0 -78
@@ -1,78 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* -* Copyright (c) 2000-2006 Silicon Graphics, Inc. -* All Rights Reserved. -*/ -#ifndef __XFS_SUPPORT_MRLOCK_H__ -#define __XFS_SUPPORT_MRLOCK_H__ - -#include <linux/rwsem.h> - -typedef struct { -struct rw_semaphore mr_lock; -#if defined(DEBUG ) || defined(XFS_WARN ) -int mr_writer; -#endif -}mrlock_t ; - -#if defined(DEBUG ) || defined(XFS_WARN ) -#define mrinit (mrp, name) \ - do { (mrp)->mr_writer = 0; init_rwsem(&(mrp)->mr_lock); } while (0) -#else -#define mrinit (mrp, name) \ - do { init_rwsem(&(mrp)->mr_lock); } while (0) -#endif - -#define mrlock_init (mrp, t,n,s) mrinit(mrp, n) -#define mrfree (mrp) do { } while (0) - -static inline void mraccess_nested (mrlock_t *mrp,int subclass) -{ -down_read_nested (&mrp->mr_lock, subclass); -} - -static inline void mrupdate_nested (mrlock_t *mrp,int subclass) -{ -down_write_nested (&mrp->mr_lock, subclass); -#if defined(DEBUG ) || defined(XFS_WARN ) - mrp->mr_writer =1 ; -#endif -} - -static inline int mrtryaccess (mrlock_t *mrp) -{ -return down_read_trylock (&mrp->mr_lock); -} - -static inline int mrtryupdate (mrlock_t *mrp) -{ -if (!down_write_trylock (&mrp->mr_lock)) -return 0 ; -#if defined(DEBUG ) || defined(XFS_WARN ) - mrp->mr_writer =1 ; -#endif -return 1 ; -} - -static inline void mrunlock_excl (mrlock_t *mrp) -{ -#if defined(DEBUG ) || defined(XFS_WARN ) - mrp->mr_writer =0 ; -#endif -up_write (&mrp->mr_lock); -} - -static inline void mrunlock_shared (mrlock_t *mrp) -{ -up_read (&mrp->mr_lock); -} - -static inline void mrdemote (mrlock_t *mrp) -{ -#if defined(DEBUG ) || defined(XFS_WARN ) - mrp->mr_writer =0 ; -#endif -downgrade_write (&mrp->mr_lock); -} - -#endif /* __XFS_SUPPORT_MRLOCK_H__ */
fs/xfs/xfs_inode.c +19 -46
131 lines not on this page · raw message
fs/xfs/xfs_inode.h +4 -3
@@ -9,6 +9,8 @@#include "xfs_inode_buf.h" #include "xfs_inode_fork.h" +#include <linux/rwsem.h> +/* * Kernel only inode definitions */
@@ -39,8 +41,8 @@ typedef struct xfs_inode {/* Transaction and locking information. */ struct xfs_inode_log_item *i_itemp;/* logging information */ -mrlock_t i_lock;/* inode lock */ -mrlock_t i_mmaplock;/* inode mmap IO lock */ +struct rw_semaphore i_lock;/* inode lock */ +struct rw_semaphore i_mmaplock;/* inode mmap IO lock */ atomic_t i_pincount;/* inode pin count */ /*
@@ -416,7 +418,6 @@ void xfs_ilock(xfs_inode_t *, uint);int xfs_ilock_nowait (xfs_inode_t *,uint );void xfs_iunlock (xfs_inode_t *,uint );void xfs_ilock_demote (xfs_inode_t *,uint ); -int xfs_isilocked (xfs_inode_t *,uint );bool xfs_is_ilocked (struct xfs_inode *,int );bool xfs_is_mmaplocked (struct xfs_inode *,int );bool xfs_is_iolocked (struct xfs_inode *,int );
fs/xfs/xfs_iops.c +2 -2
@@ -1319,9 +1319,9 @@ xfs_setup_inode(*/ lockdep_set_class (&inode->i_rwsem, &inode->i_sb->s_type->i_mutex_dir_key); -lockdep_set_class (&ip->i_lock.mr_lock, &xfs_dir_ilock_class); +lockdep_set_class (&ip->i_lock, &xfs_dir_ilock_class); }else { -lockdep_set_class (&ip->i_lock.mr_lock, &xfs_nondir_ilock_class); +lockdep_set_class (&ip->i_lock, &xfs_nondir_ilock_class); }/*
fs/xfs/xfs_linux.h +0 -1
@@ -22,7 +22,6 @@ typedef __u32 xfs_nlink_t;#include "xfs_types.h" #include "kmem.h" -#include "mrlock.h" #include <linux/semaphore.h> #include <linux/mm.h>
fs/xfs/xfs_super.c +2 -4
@@ -661,10 +661,8 @@ xfs_fs_inode_init_once(atomic_set (&ip->i_pincount,0 );spin_lock_init (&ip->i_flags_lock); -mrlock_init (&ip->i_mmaplock,MRLOCK_ALLOW_EQUAL_PRI |MRLOCK_BARRIER , -"xfsino" , ip->i_ino); -mrlock_init (&ip->i_lock,MRLOCK_ALLOW_EQUAL_PRI |MRLOCK_BARRIER , -"xfsino" , ip->i_ino); +init_rwsem (&ip->i_mmaplock); +init_rwsem (&ip->i_lock); }/*
Signature · 1 line
2.24.1