extent list locking fixes V3
cover extent list locking fixes V3
Changes from V2:
- take care to lock for data vs attr fork differently
Changes from V1:
- fixed the review feedback
- includes Bens original patch for completeness
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 1/11 xfs: no need to lock the inode in xfs_find_handle
Both the inode number and the generation do not change on a live inode.
fs/xfs/xfs_ioctl.c +0 -4
@@ -112,15 +112,11 @@ xfs_find_handle(memset (&handle.ha_fid,0 ,sizeof (handle.ha_fid)); hsize =sizeof (xfs_fsid_t); }else { -int lock_mode; - - lock_mode =xfs_ilock_map_shared (ip); handle.ha_fid.fid_len =sizeof (xfs_fid_t) -sizeof (handle.ha_fid.fid_len); handle.ha_fid.fid_pad =0 ; handle.ha_fid.fid_gen = ip->i_d.di_gen; handle.ha_fid.fid_ino = ip->i_ino; -xfs_iunlock_map_shared (ip, lock_mode); hsize =XFS_HSIZE (handle); }
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 01/11] xfs: no need to lock the inode in xfs_find_handle
Quoted 14 lines · Christoph Hellwig
Both the inode number and the generation do not change on a live inode.
Signed-off-by Christoph Hellwig <[email protected]>Index:
xfs/fs/xfs/xfs_ioctl.c
===================================================================fs/xfs/xfs_ioctl.c +0
-2@@ -112,15 +112,11 @@ xfs_find_handle(memset (&handle.ha_fid,0 ,sizeof (handle.ha_fid)); hsize =sizeof (xfs_fsid_t); }else { -int lock_mode; -
fs/xfs/xfs_ioctl.c xfs_find_handle( · line 122
Quoted 10 lines
fs/xfs/xfs_ioctl.c +0
-2- lock_mode =xfs_ilock_map_shared (ip); handle.ha_fid.fid_len =sizeof (xfs_fid_t) -sizeof (handle.ha_fid.fid_len); handle.ha_fid.fid_pad =0 ; handle.ha_fid.fid_gen = ip->i_d.di_gen; handle.ha_fid.fid_ino = ip->i_ino; -xfs_iunlock_map_shared (ip, lock_mode); hsize =XFS_HSIZE (handle); }
Agreed.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 2/11 xfs: remove xfs_iunlock_map_shared
In reply to Christoph HellwigWe can just use xfs_iunlock without any loss of clarity.
fs/xfs/xfs_bmap_util.c +1 -1
@@ -737,7 +737,7 @@ xfs_getbmap( out_free_map:kmem_free (map); out_unlock_ilock: -xfs_iunlock_map_shared (ip, lock); +xfs_iunlock (ip, lock); out_unlock_iolock:xfs_iunlock (ip,XFS_IOLOCK_SHARED );
fs/xfs/xfs_file.c +2 -2
@@ -1294,7 +1294,7 @@ out: offset =vfs_setpos (file, offset, inode->i_sb->s_maxbytes); out_unlock: -xfs_iunlock_map_shared (ip, lock); +xfs_iunlock (ip, lock);if (error)return -error;
@@ -1402,7 +1402,7 @@ out: offset =vfs_setpos (file, offset, inode->i_sb->s_maxbytes); out_unlock: -xfs_iunlock_map_shared (ip, lock); +xfs_iunlock (ip, lock);if (error)return -error;
fs/xfs/xfs_inode.c +2 -15
@@ -88,8 +88,7 @@ xfs_get_extsz_hint(* have been read in yet, and only lock the inode exclusively if they have not. * * The function returns a value which should be given to the corresponding -* xfs_iunlock_map_shared(). This value is the mode in which the lock was -* actually taken. +* xfs_iunlock() call. */ uint xfs_ilock_map_shared(
@@ -110,18 +109,6 @@ xfs_ilock_map_shared( }/* -* This is simply the unlock routine to go with xfs_ilock_map_shared(). -* All it does is call xfs_iunlock() with the given lock_mode. -*/ -void -xfs_iunlock_map_shared ( -xfs_inode_t *ip, -unsigned int lock_mode) -{ -xfs_iunlock (ip, lock_mode); -} - -/* * The xfs inode contains 2 locks: a multi-reader lock called the * i_iolock and a multi-reader lock called the i_lock. This routine * allows either or both of the locks to be obtained.
@@ -590,7 +577,7 @@ xfs_lookup( lock_mode =xfs_ilock_map_shared (dp); error =xfs_dir_lookup (NULL , dp, name, &inum, ci_name); -xfs_iunlock_map_shared (dp, lock_mode); +xfs_iunlock (dp, lock_mode);if (error) goto out;
fs/xfs/xfs_inode.h +0 -1
@@ -338,7 +338,6 @@ void xfs_iunlock(xfs_inode_t *, uint);void xfs_ilock_demote (xfs_inode_t *,uint );int xfs_isilocked (xfs_inode_t *,uint );uint xfs_ilock_map_shared (xfs_inode_t *); -void xfs_iunlock_map_shared (xfs_inode_t *,uint );int xfs_ialloc (struct xfs_trans *,xfs_inode_t *,umode_t ,xfs_nlink_t ,xfs_dev_t ,prid_t ,int ,struct xfs_buf **,xfs_inode_t **);
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 02/11] xfs: remove xfs_iunlock_map_shared
Quoted 3 lines · Christoph Hellwig
We can just use
xfs_iunlockwithout any loss of clarity.Signed-off-by Christoph Hellwig <[email protected]>
Makes sense, gets rid of an unecessary wrapper.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 3/11 xfs: rename xfs_ilock_map_shared
In reply to Christoph HellwigMake it clear that we're only locking against the extent map on the data fork. Also clean the function up a little bit.
fs/xfs/xfs_aops.c +1 -1
@@ -1217,7 +1217,7 @@ __xfs_get_blocks( lockmode =XFS_ILOCK_EXCL ;xfs_ilock (ip, lockmode); }else { - lockmode =xfs_ilock_map_shared (ip); + lockmode =xfs_ilock_data_map_shared (ip); }ASSERT (offset <= mp->m_super->s_maxbytes);
fs/xfs/xfs_file.c +3 -3
@@ -912,7 +912,7 @@ xfs_dir_open(* If there are any blocks, read-ahead block 0 as we're almost * certain to have the next operation be a read there. */ - mode =xfs_ilock_map_shared (ip); + mode =xfs_ilock_data_map_shared (ip);if (ip->i_d.di_nextents >0 )xfs_dir3_data_readahead (NULL , ip,0 ,-1 );xfs_iunlock (ip, mode);
@@ -1215,7 +1215,7 @@ xfs_seek_data(uint lock;int error; - lock =xfs_ilock_map_shared (ip); + lock =xfs_ilock_data_map_shared (ip); isize =i_size_read (inode);if (start >= isize) {
@@ -1319,7 +1319,7 @@ xfs_seek_hole(if (XFS_FORCED_SHUTDOWN (mp))return -XFS_ERROR (EIO ); - lock =xfs_ilock_map_shared (ip); + lock =xfs_ilock_data_map_shared (ip); isize =i_size_read (inode);if (start >= isize) {
fs/xfs/xfs_inode.c +6 -11
@@ -91,20 +91,15 @@ xfs_get_extsz_hint(* xfs_iunlock() call. */ uint -xfs_ilock_map_shared ( -xfs_inode_t *ip) +xfs_ilock_data_map_shared ( +struct xfs_inode *ip) { -uint lock_mode; +uint lock_mode =XFS_ILOCK_SHARED ; -if ((ip->i_d.di_format ==XFS_DINODE_FMT_BTREE ) && - ((ip->i_df.if_flags &XFS_IFEXTENTS ) ==0 )) { +if (ip->i_d.di_format ==XFS_DINODE_FMT_BTREE && + (ip->i_df.if_flags &XFS_IFEXTENTS ) ==0 ) lock_mode =XFS_ILOCK_EXCL ; - }else { - lock_mode =XFS_ILOCK_SHARED ; - } -xfs_ilock (ip, lock_mode); -return lock_mode; }
@@ -575,7 +570,7 @@ xfs_lookup(if (XFS_FORCED_SHUTDOWN (dp->i_mount))return XFS_ERROR (EIO ); - lock_mode =xfs_ilock_map_shared (dp); + lock_mode =xfs_ilock_data_map_shared (dp); error =xfs_dir_lookup (NULL , dp, name, &inum, ci_name);xfs_iunlock (dp, lock_mode);
fs/xfs/xfs_inode.h +1 -1
@@ -337,7 +337,7 @@ int xfs_ilock_nowait(xfs_inode_t *, uinvoid xfs_iunlock (xfs_inode_t *,uint );void xfs_ilock_demote (xfs_inode_t *,uint );int xfs_isilocked (xfs_inode_t *,uint ); -uint xfs_ilock_map_shared (xfs_inode_t *); +uint xfs_ilock_data_map_shared (struct xfs_inode *);int xfs_ialloc (struct xfs_trans *,xfs_inode_t *,umode_t ,xfs_nlink_t ,xfs_dev_t ,prid_t ,int ,struct xfs_buf **,xfs_inode_t **);
fs/xfs/xfs_bmap_util.c +1 -1
@@ -632,7 +632,7 @@ xfs_getbmap(*/ } - lock =xfs_ilock_map_shared (ip); + lock =xfs_ilock_data_map_shared (ip);/* * Don't let nex be bigger than the number of extents
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 03/11] xfs: rename xfs_ilock_map_shared
Quoted 4 lines · Christoph Hellwig
Make it clear that we're only locking against the extent map on the data fork. Also clean the function up a little bit.
Signed-off-by Christoph Hellwig <[email protected]>
.....
Quoted 18 lines
===================================================================
fs/xfs/xfs_inode.c +4
-5@@ -91,20 +91,15 @@ xfs_get_extsz_hint(* xfs_iunlock() call. */ uint -xfs_ilock_map_shared ( -xfs_inode_t *ip) +xfs_ilock_data_map_shared ( +struct xfs_inode *ip) { -uint lock_mode; +uint lock_mode =XFS_ILOCK_SHARED ; -if ((ip->i_d.di_format ==XFS_DINODE_FMT_BTREE ) && - ((ip->i_df.if_flags &XFS_IFEXTENTS ) ==0 )) { + if (ip->i_d.di_format == XFS_DINODE_FMT_BTREE &&
fs/xfs/xfs_inode.c xfs_get_extsz_hint( · line 104
Quoted 10 lines
fs/xfs/xfs_inode.c +1
-5+ (ip->i_df.if_flags & XFS_IFEXTENTS) == 0) lock_mode =XFS_ILOCK_EXCL ; - }else { - lock_mode =XFS_ILOCK_SHARED ; - } -xfs_ilock (ip, lock_mode); -return lock_mode; }
While we are changing this, I think it makes sense to move it to being a static inline function given how simple it is....
Otherwise it looks good.
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 03/11] xfs: rename xfs_ilock_map_shared
Quoted 2 lines · Dave Chinner
While we are changing this, I think it makes sense to move it to being a static inline function given how simple it is....
I actually tried that first, but with XFS_DINODE_FMT_BTREE in fs/xfs/xfs_dinode.h, struct xfsicdinode in xfs_log_format.h and the resulting dependencies it didn't seem workable. My inode reshuffle might provide relief eventually.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Dave Chinner
Reviewed-byRe: [PATCH 03/11] xfs: rename xfs_ilock_map_shared
Quoted 8 lines · Christoph Hellwig
Quoted 2 lines · Dave Chinner
While we are changing this, I think it makes sense to move it to being a static inline function given how simple it is....
I actually tried that first, but with
XFS_DINODE_FMT_BTREEinfs/xfs/xfs_dinode.h, struct xfsicdinode inxfs_log_format.hand the resulting dependencies it didn't seem workable. My inode reshuffle might provide relief eventually.
Ok, makes sense to leave it like that for the moment.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 4/11 xfs: add xfs_ilock_attr_map_shared
In reply to Christoph HellwigEquivalent to xfs_ilock_data_map_shared, except for the attribute fork.
Make xfs_getbmap use it if called for the attribute fork instead of xfs_ilock_data_map_shared.
fs/xfs/xfs_bmap_util.c +16 -11
@@ -617,22 +617,27 @@ xfs_getbmap(return XFS_ERROR (ENOMEM );xfs_ilock (ip,XFS_IOLOCK_SHARED ); -if (whichfork ==XFS_DATA_FORK && !(iflags &BMV_IF_DELALLOC )) { -if (ip->i_delayed_blks ||XFS_ISIZE (ip) > ip->i_d.di_size) { +if (whichfork ==XFS_DATA_FORK ) { +if (!(iflags &BMV_IF_DELALLOC ) && + (ip->i_delayed_blks ||XFS_ISIZE (ip) > ip->i_d.di_size)) { error = -filemap_write_and_wait (VFS_I (ip)->i_mapping);if (error) goto out_unlock_iolock; + +/* +* Even after flushing the inode, there can still be +* delalloc blocks on the inode beyond EOF due to +* speculative reallocation. These are not removed +* until the release function is called or the inode +* is inactivated. Hence we cannot assert here that +* ip->i_delayed_blks == 0. +*/ } -/* -* even after flushing the inode, there can still be delalloc -* blocks on the inode beyond EOF due to speculative -* preallocation. These are not removed until the release -* function is called or the inode is inactivated. Hence we -* cannot assert here that ip->i_delayed_blks == 0. -*/ - } - lock =xfs_ilock_data_map_shared (ip); + lock =xfs_ilock_data_map_shared (ip); + }else { + lock =xfs_ilock_attr_map_shared (ip); + }/* * Don't let nex be bigger than the number of extents
fs/xfs/xfs_inode.c +24 -10
@@ -77,17 +77,18 @@ xfs_get_extsz_hint( }/* -* This is a wrapper routine around the xfs_ilock() routine used to centralize -* some grungy code. It is used in places that wish to lock the inode solely -* for reading the extents. The reason these places can't just call -* xfs_ilock(SHARED) is that the inode lock also guards to bringing in of the -* extents from disk for a file in b-tree format. If the inode is in b-tree -* format, then we need to lock the inode exclusively until the extents are read -* in. Locking it exclusively all the time would limit our parallelism -* unnecessarily, though. What we do instead is check to see if the extents -* have been read in yet, and only lock the inode exclusively if they have not. +* These two are wrapper routines around the xfs_ilock() routine used to +* centralize some grungy code. They are used in places that wish to lock the +* inode solely for reading the extents. The reason these places can't just +* call xfs_ilock(ip, XFS_ILOCK_SHARED) is that the inode lock also guards to +* bringing in of the extents from disk for a file in b-tree format. If the +* inode is in b-tree format, then we need to lock the inode exclusively until +* the extents are read in. Locking it exclusively all the time would limit +* our parallelism unnecessarily, though. What we do instead is check to see +* if the extents have been read in yet, and only lock the inode exclusively +* if they have not. * -* The function returns a value which should be given to the corresponding +* The functions return a value which should be given to the corresponding * xfs_iunlock() call. */ uint
@@ -101,6 +102,19 @@ xfs_ilock_data_map_shared( lock_mode =XFS_ILOCK_EXCL ;xfs_ilock (ip, lock_mode);return lock_mode; +} + +uint +xfs_ilock_attr_map_shared ( +struct xfs_inode *ip) +{ +uint lock_mode =XFS_ILOCK_SHARED ; + +if (ip->i_d.di_aformat ==XFS_DINODE_FMT_BTREE && + (ip->i_afp->if_flags &XFS_IFEXTENTS ) ==0 ) + lock_mode =XFS_ILOCK_EXCL ; +xfs_ilock (ip, lock_mode); +return lock_mode; }/*
fs/xfs/xfs_inode.h +1 -0
@@ -338,6 +338,7 @@ void xfs_iunlock(xfs_inode_t *, uint);void xfs_ilock_demote (xfs_inode_t *,uint );int xfs_isilocked (xfs_inode_t *,uint );uint xfs_ilock_data_map_shared (struct xfs_inode *); +uint xfs_ilock_attr_map_shared (struct xfs_inode *);int xfs_ialloc (struct xfs_trans *,xfs_inode_t *,umode_t ,xfs_nlink_t ,xfs_dev_t ,prid_t ,int ,struct xfs_buf **,xfs_inode_t **);
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 04/11] xfs: add xfs_ilock_attr_map_shared
Quoted 18 lines · Christoph Hellwig
Equivalent to
xfs_ilock_data_map_shared, except for the attribute fork.Make
xfs_getbmapuse it if called for the attribute fork instead ofxfs_ilock_data_map_shared.Signed-off-by Christoph Hellwig <[email protected]>Index:
xfs/fs/xfs/xfs_bmap_util.c
===================================================================fs/xfs/xfs_bmap_util.c +1
-2@@ -617,22 +617,27 @@ xfs_getbmap(return XFS_ERROR (ENOMEM );xfs_ilock (ip,XFS_IOLOCK_SHARED ); -if (whichfork ==XFS_DATA_FORK && !(iflags &BMV_IF_DELALLOC )) { -if (ip->i_delayed_blks ||XFS_ISIZE (ip) > ip->i_d.di_size) { +if (whichfork ==XFS_DATA_FORK ) {
fs/xfs/xfs_bmap_util.c xfs_getbmap( · line 630
Quoted 10 lines
fs/xfs/xfs_bmap_util.c +7
-0+if (!(iflags &BMV_IF_DELALLOC ) && + (ip->i_delayed_blks ||XFS_ISIZE (ip) > ip->i_d.di_size)) { error = -filemap_write_and_wait (VFS_I (ip)->i_mapping);if (error) goto out_unlock_iolock; + +/* +* Even after flushing the inode, there can still be +* delalloc blocks on the inode beyond EOF due to +* speculative reallocation. These are not removed
"speculative preallocation"
Quoted 41 lines
Index:
xfs/fs/xfs/xfs_inode.c
===================================================================fs/xfs/xfs_inode.c +15
-10@@ -77,17 +77,18 @@ xfs_get_extsz_hint( }/* -* This is a wrapper routine around the xfs_ilock() routine used to centralize -* some grungy code. It is used in places that wish to lock the inode solely -* for reading the extents. The reason these places can't just call -* xfs_ilock(SHARED) is that the inode lock also guards to bringing in of the -* extents from disk for a file in b-tree format. If the inode is in b-tree -* format, then we need to lock the inode exclusively until the extents are read -* in. Locking it exclusively all the time would limit our parallelism -* unnecessarily, though. What we do instead is check to see if the extents -* have been read in yet, and only lock the inode exclusively if they have not. +* These two are wrapper routines around the xfs_ilock() routine used to +* centralize some grungy code. They are used in places that wish to lock the +* inode solely for reading the extents. The reason these places can't just +* call xfs_ilock(ip, XFS_ILOCK_SHARED) is that the inode lock also guards to +* bringing in of the extents from disk for a file in b-tree format. If the +* inode is in b-tree format, then we need to lock the inode exclusively until +* the extents are read in. Locking it exclusively all the time would limit +* our parallelism unnecessarily, though. What we do instead is check to see +* if the extents have been read in yet, and only lock the inode exclusively +* if they have not. * -* The function returns a value which should be given to the corresponding +* The functions return a value which should be given to the corresponding * xfs_iunlock() call. */ uint@@ -101,6 +102,19 @@ xfs_ilock_data_map_shared( lock_mode =XFS_ILOCK_EXCL ;xfs_ilock (ip, lock_mode);return lock_mode; +} + +uint +xfs_ilock_attr_map_shared(
fs/xfs/xfs_inode.c xfs_ilock_data_map_shared( · line 118
Quoted 10 lines
fs/xfs/xfs_inode.c +9
-0+ struct xfs_inode *ip) +{ +uint lock_mode =XFS_ILOCK_SHARED ; + +if (ip->i_d.di_aformat ==XFS_DINODE_FMT_BTREE && + (ip->i_afp->if_flags &XFS_IFEXTENTS ) ==0 ) + lock_mode =XFS_ILOCK_EXCL ; +xfs_ilock (ip, lock_mode); +return lock_mode; }
Again, I think a static inline is appropriate here...
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 04/11] xfs: add xfs_ilock_attr_map_shared
Quoted 6 lines · Dave Chinner
fs/xfs/xfs_bmap_util.c xfs_getbmap( · line 630
Quoted 4 lines
fs/xfs/xfs_bmap_util.c +4
-0+/* +* Even after flushing the inode, there can still be +* delalloc blocks on the inode beyond EOF due to +* speculative reallocation. These are not removed "speculative preallocation"
I just re-indented the comment, the wording is the original one. Maybe we'll get a commit that cares enought to fix it on the fly..
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 04/11] xfs: add xfs_ilock_attr_map_shared
Quoted 10 lines · Christoph Hellwig
Quoted 6 lines · Dave Chinner
fs/xfs/xfs_bmap_util.c xfs_getbmap( · line 630
Quoted 4 lines
fs/xfs/xfs_bmap_util.c +4
-0+/* +* Even after flushing the inode, there can still be +* delalloc blocks on the inode beyond EOF due to +* speculative reallocation. These are not removed "speculative preallocation"
I just re-indented the comment, the wording is the original one. Maybe we'll get a commit that cares enought to fix it on the fly..
Sure...
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 04/11] xfs: add xfs_ilock_attr_map_shared
In reply to Christoph HellwigQuoted 10 lines · Christoph Hellwig
Quoted 6 lines · Dave Chinner
fs/xfs/xfs_bmap_util.c xfs_getbmap( · line 630
Quoted 4 lines
fs/xfs/xfs_bmap_util.c +4
-0+/* +* Even after flushing the inode, there can still be +* delalloc blocks on the inode beyond EOF due to +* speculative reallocation. These are not removed "speculative preallocation"
I just re-indented the comment, the wording is the original one. Maybe we'll get a commit that cares enought to fix it on the fly..
Actually, I checked that before commenting on it - the original comment is correct:
626 /*
627 * even after flushing the inode, there can still be delalloc 628 * blocks on the inode beyond EOF due to speculative 629 * preallocation. These are not removed until the release 630 * function is called or the inode is inactivated. Hence we 631 * cannot assert here that ip->i_delayed_blks == 0. 632 */
I wouldn't have pointed at it if the original code had that problem... :/
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 04/11] xfs: add xfs_ilock_attr_map_shared
Dave,
Quoted 23 lines · Dave Chinner
Quoted 10 lines · Christoph Hellwig
Quoted 6 lines · Dave Chinner
fs/xfs/xfs_bmap_util.c xfs_getbmap( · line 630
Quoted 4 lines
fs/xfs/xfs_bmap_util.c +4
-0+/* +* Even after flushing the inode, there can still be +* delalloc blocks on the inode beyond EOF due to +* speculative reallocation. These are not removed "speculative preallocation"
I just re-indented the comment, the wording is the original one. Maybe we'll get a commit that cares enought to fix it on the fly..
Actually, I checked that before commenting on it - the original comment is correct:
626 /*
627 * even after flushing the inode, there can still be delalloc 628 * blocks on the inode beyond EOF due to speculative 629 * preallocation. These are not removed until the release 630 * function is called or the inode is inactivated. Hence we 631 * cannot assert here that ip->i_delayed_blks == 0. 632 */
Quoted 2 lines
I wouldn't have pointed at it if the original code had that problem... :/
If you want to extend your Reviewed-by: on this patch I will clean up the spelling mistake and pull in this series.
-Ben
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 04/11] xfs: add xfs_ilock_attr_map_shared
In reply to Dave ChinnerQuoted 2 lines · Dave Chinner
I wouldn't have pointed at it if the original code had that problem... :/
Strange. I'd swear I haven't reworded anything. I'll fix it back up.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 04/11] xfs: add xfs_ilock_attr_map_shared
Hey Christoph,
Quoted 5 lines · Christoph Hellwig
Quoted 2 lines · Dave Chinner
I wouldn't have pointed at it if the original code had that problem... :/
Strange. I'd swear I haven't reworded anything. I'll fix it back up.
I'd like to pull this series in. Are you still planning on reposting this patch?
Thanks,
Ben
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH v2 4/11 xfs: add xfs_ilock_attr_map_shared
Equivalent to xfs_ilock_data_map_shared, except for the attribute fork.
Make xfs_getbmap use it if called for the attribute fork instead of xfs_ilock_data_map_shared.
fs/xfs/xfs_bmap_util.c +16 -11
@@ -617,22 +617,27 @@ xfs_getbmap(return XFS_ERROR (ENOMEM );xfs_ilock (ip,XFS_IOLOCK_SHARED ); -if (whichfork ==XFS_DATA_FORK && !(iflags &BMV_IF_DELALLOC )) { -if (ip->i_delayed_blks ||XFS_ISIZE (ip) > ip->i_d.di_size) { +if (whichfork ==XFS_DATA_FORK ) { +if (!(iflags &BMV_IF_DELALLOC ) && + (ip->i_delayed_blks ||XFS_ISIZE (ip) > ip->i_d.di_size)) { error = -filemap_write_and_wait (VFS_I (ip)->i_mapping);if (error) goto out_unlock_iolock; + +/* +* Even after flushing the inode, there can still be +* delalloc blocks on the inode beyond EOF due to +* speculative preallocation. These are not removed +* until the release function is called or the inode +* is inactivated. Hence we cannot assert here that +* ip->i_delayed_blks == 0. +*/ } -/* -* even after flushing the inode, there can still be delalloc -* blocks on the inode beyond EOF due to speculative -* preallocation. These are not removed until the release -* function is called or the inode is inactivated. Hence we -* cannot assert here that ip->i_delayed_blks == 0. -*/ - } - lock =xfs_ilock_data_map_shared (ip); + lock =xfs_ilock_data_map_shared (ip); + }else { + lock =xfs_ilock_attr_map_shared (ip); + }/* * Don't let nex be bigger than the number of extents
fs/xfs/xfs_inode.c +24 -10
@@ -77,17 +77,18 @@ xfs_get_extsz_hint( }/* -* This is a wrapper routine around the xfs_ilock() routine used to centralize -* some grungy code. It is used in places that wish to lock the inode solely -* for reading the extents. The reason these places can't just call -* xfs_ilock(SHARED) is that the inode lock also guards to bringing in of the -* extents from disk for a file in b-tree format. If the inode is in b-tree -* format, then we need to lock the inode exclusively until the extents are read -* in. Locking it exclusively all the time would limit our parallelism -* unnecessarily, though. What we do instead is check to see if the extents -* have been read in yet, and only lock the inode exclusively if they have not. +* These two are wrapper routines around the xfs_ilock() routine used to +* centralize some grungy code. They are used in places that wish to lock the +* inode solely for reading the extents. The reason these places can't just +* call xfs_ilock(ip, XFS_ILOCK_SHARED) is that the inode lock also guards to +* bringing in of the extents from disk for a file in b-tree format. If the +* inode is in b-tree format, then we need to lock the inode exclusively until +* the extents are read in. Locking it exclusively all the time would limit +* our parallelism unnecessarily, though. What we do instead is check to see +* if the extents have been read in yet, and only lock the inode exclusively +* if they have not. * -* The function returns a value which should be given to the corresponding +* The functions return a value which should be given to the corresponding * xfs_iunlock() call. */ uint
@@ -101,6 +102,19 @@ xfs_ilock_data_map_shared( lock_mode =XFS_ILOCK_EXCL ;xfs_ilock (ip, lock_mode);return lock_mode; +} + +uint +xfs_ilock_attr_map_shared ( +struct xfs_inode *ip) +{ +uint lock_mode =XFS_ILOCK_SHARED ; + +if (ip->i_d.di_aformat ==XFS_DINODE_FMT_BTREE && + (ip->i_afp->if_flags &XFS_IFEXTENTS ) ==0 ) + lock_mode =XFS_ILOCK_EXCL ; +xfs_ilock (ip, lock_mode); +return lock_mode; }/*
fs/xfs/xfs_inode.h +1 -0
@@ -338,6 +338,7 @@ void xfs_iunlock(xfs_inode_t *, uint);void xfs_ilock_demote (xfs_inode_t *,uint );int xfs_isilocked (xfs_inode_t *,uint );uint xfs_ilock_data_map_shared (struct xfs_inode *); +uint xfs_ilock_attr_map_shared (struct xfs_inode *);int xfs_ialloc (struct xfs_trans *,xfs_inode_t *,umode_t ,xfs_nlink_t ,xfs_dev_t ,prid_t ,int ,struct xfs_buf **,xfs_inode_t **);
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 04/11 v2] xfs: add xfs_ilock_attr_map_shared
Quoted 18 lines · Christoph Hellwig
Equivalent to
xfs_ilock_data_map_shared, except for the attribute fork.Make
xfs_getbmapuse it if called for the attribute fork instead ofxfs_ilock_data_map_shared.Signed-off-by Christoph Hellwig <[email protected]>Index:
xfs/fs/xfs/xfs_bmap_util.c
===================================================================fs/xfs/xfs_bmap_util.c +1
-2@@ -617,22 +617,27 @@ xfs_getbmap(return XFS_ERROR (ENOMEM );xfs_ilock (ip,XFS_IOLOCK_SHARED ); -if (whichfork ==XFS_DATA_FORK && !(iflags &BMV_IF_DELALLOC )) { -if (ip->i_delayed_blks ||XFS_ISIZE (ip) > ip->i_d.di_size) { +if (whichfork ==XFS_DATA_FORK ) {
fs/xfs/xfs_bmap_util.c xfs_getbmap( · line 630
Quoted 10 lines
fs/xfs/xfs_bmap_util.c +7
-0+if (!(iflags &BMV_IF_DELALLOC ) && + (ip->i_delayed_blks ||XFS_ISIZE (ip) > ip->i_d.di_size)) { error = -filemap_write_and_wait (VFS_I (ip)->i_mapping);if (error) goto out_unlock_iolock; + +/* +* Even after flushing the inode, there can still be +* delalloc blocks on the inode beyond EOF due to +* speculative preallocation. These are not removed
This one has a 'p'.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 5/11 xfs: reinstate the ilock in xfs_readdir
In reply to Christoph HellwigFrom: Ben Myers <[email protected]>
Although it was removed in commit 051e7cd44ab8, ilock needs to be taken in xfs_readdir because we might have to read the extent list in from disk. This keeps other threads from reading from or writing to the extent list while it is being read in and is still in a transitional state.
This has been associated with "Access to block zero" messages on directories with large numbers of extents resulting from excessive filesytem fragmentation, as well as extent list corruption. Unfortunately no test case at this point.
--- fs/xfs/xfs_dir2_readdir.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/xfs/xfs_dir2_readdir.c +4 -0
@@ -674,6 +674,7 @@ xfs_readdir( {int rval;/* return value */ int v;/* type-checking value */ +uint lock_mode;trace_xfs_readdir (dp);
@@ -683,6 +684,7 @@ xfs_readdir(ASSERT (S_ISDIR (dp->i_d.di_mode));XFS_STATS_INC (xs_dir_getdents); + lock_mode =xfs_ilock_data_map_shared (dp);if (dp->i_d.di_format ==XFS_DINODE_FMT_LOCAL ) rval =xfs_dir2_sf_getdents (dp, ctx);else if ((rval =xfs_dir2_isblock (NULL , dp, &v)))
@@ -691,5 +693,7 @@ xfs_readdir( rval =xfs_dir2_block_getdents (dp, ctx); else rval =xfs_dir2_leaf_getdents (dp, ctx, bufsize); +xfs_iunlock (dp, lock_mode); +return rval; }
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 05/11] xfs: reinstate the ilock in xfs_readdir
Quoted 7 lines · Christoph Hellwig
From: Ben Myers <[email protected]>
Although it was removed in commit
051e7cd44ab8, ilock needs to be taken inxfs_readdirbecause we might have to read the extent list in from disk. This keeps other threads from reading from or writing to the extent list while it is being read in and is still in a transitional state.
Quoted 5 lines
This has been associated with "Access to block zero" messages on directories with large numbers of extents resulting from excessive filesytem fragmentation, as well as extent list corruption. Unfortunately no test case at this point.
Signed-off-by Ben Myers <[email protected]>
Looks good.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 6/11 xfs: take the ilock around xfs_bmapi_read in xfs_zero_remaining_bytes
In reply to Christoph Hellwigfs/xfs/xfs_bmap_util.c +6 -0
@@ -1175,9 +1175,15 @@ xfs_zero_remaining_bytes(xfs_buf_unlock (bp);for (offset = startoff; offset <= endoff; offset = lastoffset +1 ) { +uint lock_mode; + offset_fsb =XFS_B_TO_FSBT (mp, offset); nimap =1 ; + + lock_mode =xfs_ilock_data_map_shared (ip); error =xfs_bmapi_read (ip, offset_fsb,1 , &imap, &nimap,0 ); +xfs_iunlock (ip, lock_mode); +if (error || nimap <1 )break ;ASSERT (imap.br_blockcount >=1 );
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 06/11] xfs: take the ilock around xfs_bmapi_read in xfs_zero_remaining_bytes
Quoted 12 lines · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>Index:
xfs/fs/xfs/xfs_bmap_util.c
===================================================================fs/xfs/xfs_bmap_util.c +2
-0@@ -1175,9 +1175,15 @@ xfs_zero_remaining_bytes(xfs_buf_unlock (bp);for (offset = startoff; offset <= endoff; offset = lastoffset +1 ) { +uint lock_mode; +
fs/xfs/xfs_bmap_util.c xfs_zero_remaining_bytes( · line 1189
Quoted 10 lines
fs/xfs/xfs_bmap_util.c +4
-0offset_fsb =XFS_B_TO_FSBT (mp, offset); nimap =1 ; + + lock_mode =xfs_ilock_data_map_shared (ip); error =xfs_bmapi_read (ip, offset_fsb,1 , &imap, &nimap,0 ); +xfs_iunlock (ip, lock_mode); +if (error || nimap <1 )break ;ASSERT (imap.br_blockcount >=1 );
Looks good.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 7/11 xfs: use xfs_ilock_data_map_shared in xfs_qm_dqtobp
In reply to Christoph HellwigWe might not have read in the extent list at this point, so make sure we take the ilock exclusively if we have to do so.
fs/xfs/xfs_dquot.c +4 -3
@@ -469,16 +469,17 @@ xfs_qm_dqtobp(struct xfs_mount *mp = dqp->q_mount;xfs_dqid_t id =be32_to_cpu (dqp->q_core.d_id);struct xfs_trans *tp = (tpp ? *tpp :NULL ); +uint lock_mode; dqp->q_fileoffset = (xfs_fileoff_t )id / mp->m_quotainfo->qi_dqperchunk; -xfs_ilock (quotip,XFS_ILOCK_SHARED ); + lock_mode =xfs_ilock_data_map_shared (quotip);if (!xfs_this_quota_on (dqp->q_mount, dqp->dq_flags)) {/* * Return if this type of quotas is turned off while we * didn't have the quota inode lock. */ -xfs_iunlock (quotip,XFS_ILOCK_SHARED ); +xfs_iunlock (quotip, lock_mode);return ESRCH ; }
@@ -488,7 +489,7 @@ xfs_qm_dqtobp( error =xfs_bmapi_read (quotip, dqp->q_fileoffset,XFS_DQUOT_CLUSTER_SIZE_FSB , &map, &nmaps,0 ); -xfs_iunlock (quotip,XFS_ILOCK_SHARED ); +xfs_iunlock (quotip, lock_mode);if (error)return error;
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 07/11] xfs: use xfs_ilock_data_map_shared in xfs_qm_dqtobp
Quoted 30 lines · Christoph Hellwig
We might not have read in the extent list at this point, so make sure we take the ilock exclusively if we have to do so.
Signed-off-by Christoph Hellwig <[email protected]>Index:
xfs/fs/xfs/xfs_dquot.c
===================================================================fs/xfs/xfs_dquot.c +3
-2@@ -469,16 +469,17 @@ xfs_qm_dqtobp(struct xfs_mount *mp = dqp->q_mount;xfs_dqid_t id =be32_to_cpu (dqp->q_core.d_id);struct xfs_trans *tp = (tpp ? *tpp :NULL ); +uint lock_mode; dqp->q_fileoffset = (xfs_fileoff_t )id / mp->m_quotainfo->qi_dqperchunk; -xfs_ilock (quotip,XFS_ILOCK_SHARED ); + lock_mode =xfs_ilock_data_map_shared (quotip);if (!xfs_this_quota_on (dqp->q_mount, dqp->dq_flags)) {/* * Return if this type of quotas is turned off while we * didn't have the quota inode lock. */ -xfs_iunlock (quotip,XFS_ILOCK_SHARED ); +xfs_iunlock (quotip, lock_mode);return ESRCH ; }
fs/xfs/xfs_dquot.c xfs_qm_dqtobp( · line 494
Quoted 7 lines
fs/xfs/xfs_dquot.c +1
-1@@ -488,7 +489,7 @@ xfs_qm_dqtobp( error =xfs_bmapi_read (quotip, dqp->q_fileoffset,XFS_DQUOT_CLUSTER_SIZE_FSB , &map, &nmaps,0 ); -xfs_iunlock (quotip,XFS_ILOCK_SHARED ); +xfs_iunlock (quotip, lock_mode);if (error)return error;
Looks fine - it doesn't change the race condition w/ dquot creation at all, so we can ignore that for now...
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 8/11 xfs: use xfs_ilock_data_map_shared in xfs_qm_dqiterate
In reply to Christoph HellwigWe might not have read in the extent list at this point, so make sure we take the ilock exclusively if we have to do so.
fs/xfs/xfs_qm.c +4 -2
@@ -1193,16 +1193,18 @@ xfs_qm_dqiterate( lblkno =0 ; maxlblkcnt =XFS_B_TO_FSB (mp, mp->m_super->s_maxbytes); do { + uint lock_mode; + nmaps = XFS_DQITER_MAP_SIZE; /* * We aren't changing the inode itself. Just changing * some of its data. No new blocks are added here, and * the inode is never added to the transaction. */ - xfs_ilock(qip, XFS_ILOCK_SHARED); + lock_mode = xfs_ilock_data_map_shared(qip); error = xfs_bmapi_read(qip, lblkno, maxlblkcnt - lblkno, map, &nmaps, 0); - xfs_iunlock(qip, XFS_ILOCK_SHARED); + xfs_iunlock(qip, lock_mode); if (error) break;
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 08/11] xfs: use xfs_ilock_data_map_shared in xfs_qm_dqiterate
Quoted 19 lines · Christoph Hellwig
We might not have read in the extent list at this point, so make sure we take the ilock exclusively if we have to do so.
Signed-off-by Christoph Hellwig <[email protected]>Index:
xfs/fs/xfs/xfs_qm.c
===================================================================fs/xfs/xfs_qm.c +2
-0@@ -1193,16 +1193,18 @@ xfs_qm_dqiterate( lblkno =0 ; maxlblkcnt =XFS_B_TO_FSB (mp, mp->m_super->s_maxbytes); do { + uint lock_mode; + nmaps = XFS_DQITER_MAP_SIZE; /* * We aren't changing the inode itself. Just changing * some of its data. No new blocks are added here, and
fs/xfs/xfs_qm.c xfs_qm_dqiterate( · line 1209
Quoted 10 lines
fs/xfs/xfs_qm.c +2
-2* the inode is never added to the transaction. */ -xfs_ilock (qip,XFS_ILOCK_SHARED ); + lock_mode =xfs_ilock_data_map_shared (qip); error =xfs_bmapi_read (qip, lblkno, maxlblkcnt - lblkno, map, &nmaps,0 ); -xfs_iunlock (qip,XFS_ILOCK_SHARED ); +xfs_iunlock (qip, lock_mode);if (error)break ;
looks good.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 9/11 xfs: use xfs_ilock_attr_map_shared in xfs_attr_get
In reply to Christoph HellwigWe might not have read in the extent list at this point, so make sure we take the ilock exclusively if we have to do so.
fs/xfs/xfs_attr.c +3 -2
@@ -164,6 +164,7 @@ xfs_attr_get( {int error;struct xfs_name xname; +uint lock_mode;XFS_STATS_INC (xs_attr_get);
@@ -174,9 +175,9 @@ xfs_attr_get(if (error)return error; -xfs_ilock (ip,XFS_ILOCK_SHARED ); + lock_mode =xfs_ilock_attr_map_shared (ip); error =xfs_attr_get_int (ip, &xname, value, valuelenp, flags); -xfs_iunlock (ip,XFS_ILOCK_SHARED ); +xfs_iunlock (ip, lock_mode);return (error); }
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 09/11] xfs: use xfs_ilock_attr_map_shared in xfs_attr_get
Quoted 18 lines · Christoph Hellwig
We might not have read in the extent list at this point, so make sure we take the ilock exclusively if we have to do so.
Signed-off-by Christoph Hellwig <[email protected]>Index:
xfs/fs/xfs/xfs_attr.c
===================================================================fs/xfs/xfs_attr.c +1
-0@@ -164,6 +164,7 @@ xfs_attr_get( {int error;struct xfs_name xname; +uint lock_mode;XFS_STATS_INC (xs_attr_get);
fs/xfs/xfs_attr.c xfs_attr_get( · line 182
Quoted 10 lines
fs/xfs/xfs_attr.c +2
-2@@ -174,9 +175,9 @@ xfs_attr_get(if (error)return error; -xfs_ilock (ip,XFS_ILOCK_SHARED ); + lock_mode =xfs_ilock_attr_map_shared (ip); error =xfs_attr_get_int (ip, &xname, value, valuelenp, flags); -xfs_iunlock (ip,XFS_ILOCK_SHARED ); +xfs_iunlock (ip, lock_mode);return (error); }
Yup, that should fix the assert problem. :)
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 10/11 xfs: use xfs_ilock_attr_map_shared in xfs_attr_list_int
In reply to Christoph HellwigWe might not have read in the extent list at this point, so make sure we take the ilock exclusively if we have to do so.
fs/xfs/xfs_attr_list.c +3 -5
@@ -507,17 +507,17 @@ xfs_attr_list_int( {int error;xfs_inode_t *dp = context->dp; +uint lock_mode;XFS_STATS_INC (xs_attr_list);if (XFS_FORCED_SHUTDOWN (dp->i_mount))return EIO ; -xfs_ilock (dp,XFS_ILOCK_SHARED ); -/* * Decide on what work routines to call based on the inode size. */ + lock_mode =xfs_ilock_attr_map_shared (dp);if (!xfs_inode_hasattr (dp)) { error =0 ; }else if (dp->i_d.di_aformat ==XFS_DINODE_FMT_LOCAL ) {
@@ -527,9 +527,7 @@ xfs_attr_list_int( }else { error =xfs_attr_node_list (context); } - -xfs_iunlock (dp,XFS_ILOCK_SHARED ); - +xfs_iunlock (dp, lock_mode);return error; }
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 10/11] xfs: use xfs_ilock_attr_map_shared in xfs_attr_list_int
Quoted 30 lines · Christoph Hellwig
We might not have read in the extent list at this point, so make sure we take the ilock exclusively if we have to do so.
Signed-off-by Christoph Hellwig <[email protected]>Index:
xfs/fs/xfs/xfs_attr_list.c
===================================================================fs/xfs/xfs_attr_list.c +2
-2@@ -507,17 +507,17 @@ xfs_attr_list_int( {int error;xfs_inode_t *dp = context->dp; +uint lock_mode;XFS_STATS_INC (xs_attr_list);if (XFS_FORCED_SHUTDOWN (dp->i_mount))return EIO ; -xfs_ilock (dp,XFS_ILOCK_SHARED ); -/* * Decide on what work routines to call based on the inode size. */ + lock_mode =xfs_ilock_attr_map_shared (dp);if (!xfs_inode_hasattr (dp)) { error =0 ; }else if (dp->i_d.di_aformat ==XFS_DINODE_FMT_LOCAL ) {
fs/xfs/xfs_attr_list.c xfs_attr_list_int( · line 532
Quoted 9 lines
fs/xfs/xfs_attr_list.c +1
-3@@ -527,9 +527,7 @@ xfs_attr_list_int( }else { error =xfs_attr_node_list (context); } - -xfs_iunlock (dp,XFS_ILOCK_SHARED ); - +xfs_iunlock (dp, lock_mode);return error; }
Looks good.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 11/11 xfs: assert that we hold the ilock for extent map access
In reply to Christoph HellwigMake sure that xfs_bmapi_read has the ilock held in some way, and that xfs_bmapi_write, xfs_bmapi_delay, xfs_bunmapi and xfs_iread_extents are called with the ilock held exclusively.
fs/xfs/xfs_bmap.c +3 -0
@@ -3997,6 +3997,7 @@ xfs_bmapi_read(ASSERT (*nmap >=1 );ASSERT (!(flags & ~(XFS_BMAPI_ATTRFORK |XFS_BMAPI_ENTIRE |XFS_BMAPI_IGSTATE ))); +ASSERT (xfs_isilocked (ip,XFS_ILOCK_SHARED |XFS_ILOCK_EXCL )); if (unlikely(XFS_TEST_ERROR( (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS &&
@@ -4191,6 +4192,7 @@ xfs_bmapi_delay(ASSERT (*nmap >=1 );ASSERT (*nmap <=XFS_BMAP_MAX_NMAP );ASSERT (!(flags & ~XFS_BMAPI_ENTIRE )); +ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); if (unlikely(XFS_TEST_ERROR( (XFS_IFORK_FORMAT(ip, XFS_DATA_FORK) != XFS_DINODE_FMT_EXTENTS &&
@@ -4484,6 +4486,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 )); if (unlikely(XFS_TEST_ERROR( (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS &&
fs/xfs/xfs_inode_fork.c +2 -0
@@ -431,6 +431,8 @@ xfs_iread_extents(xfs_ifork_t *ifp;xfs_extnum_t nextents; +ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +if (unlikely (XFS_IFORK_FORMAT (ip, whichfork) !=XFS_DINODE_FMT_BTREE )) {XFS_ERROR_REPORT ("xfs_iread_extents" ,XFS_ERRLEVEL_LOW , ip->i_mount);
fs/xfs/xfs_bmap.c +1 -0
@@ -5038,6 +5038,7 @@ xfs_bunmapi(if (XFS_FORCED_SHUTDOWN (mp))return XFS_ERROR (EIO ); +ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL ));ASSERT (len >0 );ASSERT (nexts >=0 );
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 11/11] xfs: assert that we hold the ilock for extent map access
Quoted 52 lines · Christoph Hellwig
Make sure that
xfs_bmapi_readhas the ilock held in some way, and thatxfs_bmapi_write,xfs_bmapi_delay,xfs_bunmapiandxfs_iread_extentsare called with the ilock held exclusively.Signed-off-by Christoph Hellwig <[email protected]>Index:
xfs/fs/xfs/xfs_bmap.c
===================================================================fs/xfs/xfs_bmap.c +3
-0@@ -3997,6 +3997,7 @@ xfs_bmapi_read(ASSERT (*nmap >=1 );ASSERT (!(flags & ~(XFS_BMAPI_ATTRFORK |XFS_BMAPI_ENTIRE |XFS_BMAPI_IGSTATE ))); +ASSERT (xfs_isilocked (ip,XFS_ILOCK_SHARED |XFS_ILOCK_EXCL )); if (unlikely(XFS_TEST_ERROR( (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS &&@@ -4191,6 +4192,7 @@ xfs_bmapi_delay(ASSERT (*nmap >=1 );ASSERT (*nmap <=XFS_BMAP_MAX_NMAP );ASSERT (!(flags & ~XFS_BMAPI_ENTIRE )); +ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); if (unlikely(XFS_TEST_ERROR( (XFS_IFORK_FORMAT(ip, XFS_DATA_FORK) != XFS_DINODE_FMT_EXTENTS &&@@ -4484,6 +4486,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 )); if (unlikely(XFS_TEST_ERROR( (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS &&Index:
xfs/fs/xfs/xfs_inode_fork.c
===================================================================fs/xfs/xfs_inode_fork.c +2
-0@@ -431,6 +431,8 @@ xfs_iread_extents(xfs_ifork_t *ifp;xfs_extnum_t nextents; +ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); +if (unlikely (XFS_IFORK_FORMAT (ip, whichfork) !=XFS_DINODE_FMT_BTREE )) {XFS_ERROR_REPORT ("xfs_iread_extents" ,XFS_ERRLEVEL_LOW , ip->i_mount);Index:
xfs/fs/xfs/xfs_bmap.c
===================================================================
fs/xfs/xfs_bmap.c xfs_bunmapi( · line 5043
Quoted 6 lines
fs/xfs/xfs_bmap.c +1
-0@@ -5038,6 +5038,7 @@ xfs_bunmapi(if (XFS_FORCED_SHUTDOWN (mp))return XFS_ERROR (EIO ); +ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL ));ASSERT (len >0 );ASSERT (nexts >=0 );
I can't think of anywhere else we need to add asserts for this, so it seems fine to me.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs