xfs: add support FALLOC_FL_COLLAPSE_RANGE for fallocate
Subsystems (2)
PATCH v2 2/7 xfs: add support FALLOC_FL_COLLAPSE_RANGE for fallocate
From: Namjae Jeon <[email protected]>
Add support FALLOC_FL_COLLAPSE_RANGE for fallocate.
--- fs/xfs/xfs_bmap.c | 174 ++++++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_bmap.h | 3 + fs/xfs/xfs_bmap_util.c | 96 ++++++++++++++++++++++++++ fs/xfs/xfs_bmap_util.h | 2 + fs/xfs/xfs_file.c | 20 ++++-- fs/xfs/xfs_fs.h | 6 ++ 6 files changed, 296 insertions(+), 5 deletions(-)
fs/xfs/xfs_bmap.c +174 -0
@@ -5356,3 +5356,177 @@ error0: }return error; } + +/* +* Update extents by shifting them downwards into a hole. +* At max count number of extents will be shifted and *current_ext +* is the extent number which is currently being shifted. +* This function will return error if the hole is not present +* while shifting extents. On success, 0 is returned. +*/ +int +xfs_bmap_shift_extents ( +struct xfs_trans *tp, +struct xfs_inode *ip, +int *done, +xfs_fileoff_t start_fsb, +xfs_fileoff_t shift, +xfs_extnum_t *current_ext, +xfs_fsblock_t *firstblock, +struct xfs_bmap_free *flist, +int count) +{ +struct xfs_btree_cur *cur; +struct xfs_bmbt_rec_host *gotp; +struct xfs_bmbt_irec left; +struct xfs_mount *mp = ip->i_mount; +struct xfs_ifork *ifp; +xfs_extnum_t nexts =0 ; +xfs_fileoff_t startoff; +int error =0 ; +int i; +int whichfork =XFS_DATA_FORK ; +int state; +int logflags; +xfs_filblks_t blockcount =0 ; + +if (unlikely (XFS_TEST_ERROR ( + (XFS_IFORK_FORMAT (ip, whichfork) !=XFS_DINODE_FMT_EXTENTS && +XFS_IFORK_FORMAT (ip, whichfork) !=XFS_DINODE_FMT_BTREE ), + mp,XFS_ERRTAG_BMAPIFORMAT ,XFS_RANDOM_BMAPIFORMAT ))) { +XFS_ERROR_REPORT ("xfs_bmap_shift_extents" , +XFS_ERRLEVEL_LOW , mp); +return XFS_ERROR (EFSCORRUPTED ); + } + +if (XFS_FORCED_SHUTDOWN (mp)) +return XFS_ERROR (EIO ); + + ifp =XFS_IFORK_PTR (ip, whichfork); + +if (!(ifp->if_flags &XFS_IFEXTENTS )) { +/* Read in all the extents */ + error =xfs_iread_extents (tp, ip, whichfork); +if (error) +return error; + } + +if (!*current_ext) { + gotp =xfs_iext_bno_to_ext (ifp, start_fsb, current_ext); +/* +* gotp can be null in 2 cases: 1) if there are no extents +* or 2) start_fsb lies in a hole beyond which there are +* no extents. Either way, we are done. +*/ +if (!gotp) { + *done =1 ; +return 0 ; + } + } + +/* We are going to change core inode */ + logflags =XFS_ILOG_CORE ; + +if (ifp->if_flags &XFS_IFBROOT ) { + cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); + cur->bc_private.b.firstblock = *firstblock; + cur->bc_private.b.flist = flist; + cur->bc_private.b.flags =0 ; + } +else { + cur =NULL ; + logflags |=XFS_ILOG_DEXT ; + } + +while (nexts++ < count && + *current_ext <XFS_IFORK_NEXTENTS (ip, whichfork)) { + state =0 ; + + gotp =xfs_iext_get_ext (ifp, *current_ext); + startoff =xfs_bmbt_get_startoff (gotp); + startoff -= shift; + +/* +* Before shifting extent into hole, make sure that the hole +* is large enough to accomodate the shift. +*/ +if (*current_ext) { + state |=BMAP_LEFT_VALID ; +xfs_bmbt_get_all (xfs_iext_get_ext (ifp, + *current_ext -1 ), &left); + +if (isnullstartblock (left.br_startblock)) + state |=BMAP_LEFT_DELAY ; + +if (startoff < left.br_startoff + left.br_blockcount) + error =XFS_ERROR (EFSCORRUPTED ); + + }else if (startoff >xfs_bmbt_get_startoff (gotp)) +/* Hole is at the start but not large enough */ + error =XFS_ERROR (EFSCORRUPTED ); + +if (error) + goto del_cursor; + +/* Check if we can merge 2 adjacent extents */ +if ((state &BMAP_LEFT_VALID ) && !(state &BMAP_LEFT_DELAY ) && + left.br_startoff + left.br_blockcount == startoff && + left.br_startblock + left.br_blockcount == +xfs_bmbt_get_startblock (gotp) && +xfs_bmbt_get_state (gotp) == left.br_state && + left.br_blockcount +xfs_bmbt_get_blockcount (gotp) <= +MAXEXTLEN ) { + blockcount = + left.br_blockcount +xfs_bmbt_get_blockcount (gotp); + state |=BMAP_LEFT_CONTIG ; +xfs_iext_remove (ip, *current_ext,1 ,0 ); +XFS_IFORK_NEXT_SET (ip, whichfork, +XFS_IFORK_NEXTENTS (ip, whichfork) -1 ); + gotp =xfs_iext_get_ext (ifp, --*current_ext); + } + +if (cur) { + error =xfs_bmbt_lookup_eq (cur, +xfs_bmbt_get_startoff (gotp), +xfs_bmbt_get_startblock (gotp), +xfs_bmbt_get_blockcount (gotp), + &i); +if (error) + goto del_cursor; +XFS_WANT_CORRUPTED_GOTO (i ==1 , del_cursor); + } + +if (state &BMAP_LEFT_CONTIG ) { +/* We have to update extent block count */ +xfs_bmbt_set_blockcount (gotp, blockcount); + }else { +/* We have to update the startoff */ +xfs_bmbt_set_startoff (gotp, startoff); + } + +if (cur) { + error =xfs_bmbt_update (cur, +xfs_bmbt_get_startoff (gotp), +xfs_bmbt_get_startblock (gotp), +xfs_bmbt_get_blockcount (gotp), +xfs_bmbt_get_state (gotp)); +if (error) + goto del_cursor; + } + + (*current_ext)++; + } + +/* Check if we are done */ +if (*current_ext ==XFS_IFORK_NEXTENTS (ip, whichfork)) + *done =1 ; + +del_cursor: +if (cur) +xfs_btree_del_cursor (cur, + error ?XFS_BTREE_ERROR :XFS_BTREE_NOERROR ); + +xfs_trans_log_inode (tp, ip, logflags); + +return error; +}
fs/xfs/xfs_bmap.h +3 -0
@@ -169,5 +169,8 @@ int xfs_bunmapi(struct xfs_trans *tp, struct xfs_inode *ip,int xfs_check_nostate_extents (struct xfs_ifork *ifp,xfs_extnum_t idx,xfs_extnum_t num);uint xfs_default_attroffset (struct xfs_inode *ip); +int xfs_bmap_shift_extents (struct xfs_trans *,struct xfs_inode *, +int *,xfs_fileoff_t ,xfs_fileoff_t ,xfs_extnum_t *, +xfs_fsblock_t *,struct xfs_bmap_free *,int );#endif /* __XFS_BMAP_H__ */
fs/xfs/xfs_bmap_util.c +96 -0
114 lines not on this page · raw message
fs/xfs/xfs_bmap_util.h +2 -0
@@ -97,6 +97,8 @@ int xfs_change_file_space(struct xfs_inode *ip, int cmd, xfs_flock64_t *bf, xfs_off_t offset, int attr_flags); +int xfs_collapse_file_space (struct xfs_inode *,loff_t ,loff_t ,int ); +/* EOF block manipulation functions */ bool xfs_can_free_eofblocks (struct xfs_inode *ip,bool force); int xfs_free_eofblocks(struct xfs_mount *mp, struct xfs_inode *ip,
fs/xfs/xfs_file.c +15 -5
@@ -807,7 +807,8 @@ xfs_file_fallocate(int cmd =XFS_IOC_RESVSP ;int attr_flags =XFS_ATTR_NOLOCK ; -if (mode & ~(FALLOC_FL_KEEP_SIZE |FALLOC_FL_PUNCH_HOLE )) +if (mode & ~(FALLOC_FL_KEEP_SIZE |FALLOC_FL_PUNCH_HOLE | +FALLOC_FL_COLLAPSE_RANGE ))return -EOPNOTSUPP ; bf.l_whence =0 ;
@@ -819,10 +820,19 @@ xfs_file_fallocate(if (mode &FALLOC_FL_PUNCH_HOLE ) cmd =XFS_IOC_UNRESVSP ; -/* check the new inode size is valid before allocating */ -if (!(mode &FALLOC_FL_KEEP_SIZE ) && - offset + len >i_size_read (inode)) { +/* Shrink size in case of FALLOC_FL_COLLAPSE_RANGE */ +if (mode &FALLOC_FL_COLLAPSE_RANGE ) { + cmd =XFS_COLLAPSE_RANGE ; +if ((offset + len) >i_size_read (inode)) + new_size = offset; +else + new_size =i_size_read (inode) - len; + }else if (!(mode &FALLOC_FL_KEEP_SIZE ) && + offset + len >i_size_read (inode)) new_size = offset + len; + +/* check the new inode size is valid before allocating */ +if (new_size || mode &FALLOC_FL_COLLAPSE_RANGE ) { error =inode_newsize_ok (inode, new_size);if (error) goto out_unlock;
@@ -836,7 +846,7 @@ xfs_file_fallocate( goto out_unlock;/* Change file size if needed */ -if (new_size) { +if (new_size || mode &FALLOC_FL_COLLAPSE_RANGE ) {struct iattr iattr; iattr.ia_valid =ATTR_SIZE ;
fs/xfs/xfs_fs.h +6 -0
@@ -516,6 +516,12 @@ typedef struct xfs_swapext#define XFS_IOC_GETBMAPX _IOWR('X', 56, struct getbmap)#define XFS_IOC_ZERO_RANGE _IOW ('X', 57, struct xfs_flock64)#define XFS_IOC_FREE_EOFBLOCKS _IOR ('X', 58, struct xfs_eofblocks) +/* +* Although there is no ioctl implemented yet, we reserve an ioctl number for +* representing collapse range operation to avoid any possible collision in +* switch case of xfs_change_file_space. +*/ +#define XFS_COLLAPSE_RANGE _IOW('X', 59, struct xfs_flock64)/* * ioctl commands that replace IRIX syssgi()'s
Signature · 6 lines
1.7.9.5 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 24 lines · Namjae Jeon
From: Namjae Jeon<[email protected]>
Add support
FALLOC_FL_COLLAPSE_RANGEfor fallocate.Signed-off-by Namjae Jeon<[email protected]>Signed-off-by Ashish Sangwan<[email protected]>---
fs/xfs/xfs_bmap.c +16
-0+/* Check if we can merge 2 adjacent extents */ +if ((state &BMAP_LEFT_VALID ) && !(state &BMAP_LEFT_DELAY ) && + left.br_startoff + left.br_blockcount == startoff && + left.br_startblock + left.br_blockcount == +xfs_bmbt_get_startblock (gotp) && +xfs_bmbt_get_state (gotp) == left.br_state && + left.br_blockcount +xfs_bmbt_get_blockcount (gotp) <= +MAXEXTLEN ) { + blockcount = + left.br_blockcount +xfs_bmbt_get_blockcount (gotp); + state |=BMAP_LEFT_CONTIG ; +xfs_iext_remove (ip, *current_ext,1 ,0 ); +XFS_IFORK_NEXT_SET (ip, whichfork, +XFS_IFORK_NEXTENTS (ip, whichfork) -1 ); + gotp =xfs_iext_get_ext (ifp, --*current_ext); + }
fs/xfs/xfs_bmap.c error0: · line 5496
Quoted 10 lines
fs/xfs/xfs_bmap.c +10
-0+ +if (cur) { + error =xfs_bmbt_lookup_eq (cur, +xfs_bmbt_get_startoff (gotp), +xfs_bmbt_get_startblock (gotp), +xfs_bmbt_get_blockcount (gotp), + &i); +if (error) + goto del_cursor; +XFS_WANT_CORRUPTED_GOTO (i ==1 , del_cursor);
I can reliably trigger this XFS_WANT_CORRUPTED_GOTO() with a fsstress that fills the filesystem:
xfstests > ltp/fsstress -d /mnt/scratch -s 1370236858 -p 512 -n 8192 &
xfstests > xfs_info /mnt/scratch
meta-data=/dev/sda7 isize=256 agcount=4, agsize=2228515 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0
data = bsize=4096 blocks=8914059, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=4352, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0 XFS: Assertion failed: fs_is_ok, file: fs/xfs/xfs_bmap.c, line: 5511
------------[ cut here ]------------ kernel BUG at fs/xfs/xfs_message.c:107! invalid opcode: 0000 [#1] SMP DEBUG_PAGEALLOC Modules linked in: e1000e xfs exportfs libcrc32c ext3 jbd CPU: 3 PID: 6341 Comm: fsstress Not tainted 3.15.0-rc5+ #1 Hardware name: SGI.COM AltixXE210/S5000PAL0, BIOS S5000.86B.11.00.0096.011320091422 01/13/2009 task: ffff88081ec991a0 ti: ffff88081ecca000 task.ti: ffff88081ecca000 RIP: 0010:[<ffffffffa005a7cd>] [<ffffffffa005a7cd>] assfail+0x1d/0x30
[xfs]
RSP: 0018:ffff88081eccbcd8 EFLAGS: 00010296
RAX: 0000000000000044 RBX: 0000000000000000 RCX: 0000000000000000
RDX: ffff88085bccda50 RSI: ffff88085bccd1c8 RDI: ffff88085bccd1c8
RBP: ffff88081eccbcd8 R08: 0000000000000316 R09: 0000000000000003
R10: 0000000000000316 R11: 0000000000000006 R12: 00000000000002d6
R13: ffff88009f778d00 R14: ffff88081eccbe10 R15: ffff8807fa0d4000
FS: 00007fd496c57700(0000) GS:ffff88085bcc0000(0000)
knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b
CR2: 00007fd4902e0e88 CR3: 000000081ecbc000 CR4: 00000000000007e0
Stack: ffff88081eccbda8 ffffffffa00769f4 ffff8805df5bbba0 0000000000000079 ffff88081eccbe14 ffff8805ddff5b00 0000000000000000 ffff8807fa0d4040 0000000100000001 ffff88066a5ddef0 00000000000002c5 0000000000c11a01 Call Trace: [<ffffffffa00769f4>] xfs_bmap_shift_extents+0x184/0x5a0 [xfs] [<ffffffffa0047c7c>] xfs_collapse_file_space+0x15c/0x250 [xfs] [<ffffffffa004e094>] xfs_file_fallocate+0x354/0x380 [xfs] [<ffffffff81142564>] ? __sb_start_write+0x64/0xf0 [<ffffffff81274e0c>] ? selinux_file_permission+0xec/0x130 [<ffffffff8113f270>] do_fallocate+0x150/0x170 [<ffffffff8113f2de>] SyS_fallocate+0x4e/0x80 [<ffffffff817b42e2>] system_call_fastpath+0x16/0x1b Code: 00 00 00 48 89 45 c8 e8 42 fc ff ff c9 c3 55 41 89 d0 48 89 f1 48 89 fa 48 c7 c6 d0 3b 0d a0 31 ff 48 89 e5 31 c0 e8 93 ff ff ff <0f> 0b eb fe 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 55 0f RIP [<ffffffffa005a7cd>] assfail+0x1d/0x30 [xfs] RSP <ffff88081eccbcd8> ---[ end trace 40b8d37513d3de71 ]--- Kernel panic - not syncing: Fatal exception Kernel Offset: 0x0 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffff9fffffff) ---[ end Kernel panic - not syncing: Fatal exception
--Mark.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 39 lines · Mark Tinguely
Quoted 24 lines · Namjae Jeon
From: Namjae Jeon<[email protected]>
Add support
FALLOC_FL_COLLAPSE_RANGEfor fallocate.Signed-off-by Namjae Jeon<[email protected]>Signed-off-by Ashish Sangwan<[email protected]>---
fs/xfs/xfs_bmap.c +16
-0+/* Check if we can merge 2 adjacent extents */ +if ((state &BMAP_LEFT_VALID ) && !(state &BMAP_LEFT_DELAY ) && + left.br_startoff + left.br_blockcount == startoff && + left.br_startblock + left.br_blockcount == +xfs_bmbt_get_startblock (gotp) && +xfs_bmbt_get_state (gotp) == left.br_state && + left.br_blockcount +xfs_bmbt_get_blockcount (gotp) <= +MAXEXTLEN ) { + blockcount = + left.br_blockcount +xfs_bmbt_get_blockcount (gotp); + state |=BMAP_LEFT_CONTIG ; +xfs_iext_remove (ip, *current_ext,1 ,0 ); +XFS_IFORK_NEXT_SET (ip, whichfork, +XFS_IFORK_NEXTENTS (ip, whichfork) -1 ); + gotp =xfs_iext_get_ext (ifp, --*current_ext); + }fs/xfs/xfs_bmap.c error0: · line 5496
Quoted 10 lines
fs/xfs/xfs_bmap.c +10
-0+ +if (cur) { + error =xfs_bmbt_lookup_eq (cur, +xfs_bmbt_get_startoff (gotp), +xfs_bmbt_get_startblock (gotp), +xfs_bmbt_get_blockcount (gotp), + &i); +if (error) + goto del_cursor; +XFS_WANT_CORRUPTED_GOTO (i ==1 , del_cursor);I can reliably trigger this
XFS_WANT_CORRUPTED_GOTO()with a fsstress that fills the filesystem:
Quoted 1 line
xfstests > ltp/fsstress -d
/mnt/scratch-s 1370236858 -p 512 -n 8192 &
Hasn't reproduced after 10 minutes of running at ENOSPC here - how long does it take to reproduce? What storage hardware are you testing on? How many CPUs? RAM? ....
http://xfs.org/index.php/XFS_FAQ#Q:_What_information_should_I_include_when_reporting_a_problem.3F
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 46 lines · Dave Chinner
Quoted 39 lines · Mark Tinguely
Quoted 24 lines · Namjae Jeon
From: Namjae Jeon<[email protected]>
Add support
FALLOC_FL_COLLAPSE_RANGEfor fallocate.Signed-off-by Namjae Jeon<[email protected]>Signed-off-by Ashish Sangwan<[email protected]>---
fs/xfs/xfs_bmap.c +16
-0+/* Check if we can merge 2 adjacent extents */ +if ((state&BMAP_LEFT_VALID )&& !(state&BMAP_LEFT_DELAY )&& + left.br_startoff + left.br_blockcount == startoff&& + left.br_startblock + left.br_blockcount == +xfs_bmbt_get_startblock (gotp)&& +xfs_bmbt_get_state (gotp) == left.br_state&& + left.br_blockcount +xfs_bmbt_get_blockcount (gotp)<= +MAXEXTLEN ) { + blockcount = + left.br_blockcount +xfs_bmbt_get_blockcount (gotp); + state |=BMAP_LEFT_CONTIG ; +xfs_iext_remove (ip, *current_ext,1 ,0 ); +XFS_IFORK_NEXT_SET (ip, whichfork, +XFS_IFORK_NEXTENTS (ip, whichfork) -1 ); + gotp =xfs_iext_get_ext (ifp, --*current_ext); + }fs/xfs/xfs_bmap.c error0: · line 5496
Quoted 10 lines
fs/xfs/xfs_bmap.c +10
-0+ +if (cur) { + error =xfs_bmbt_lookup_eq (cur, +xfs_bmbt_get_startoff (gotp), +xfs_bmbt_get_startblock (gotp), +xfs_bmbt_get_blockcount (gotp), + &i); +if (error) + goto del_cursor; +XFS_WANT_CORRUPTED_GOTO (i ==1 , del_cursor);I can reliably trigger this
XFS_WANT_CORRUPTED_GOTO()with a fsstress that fills the filesystem:Quoted 1 line
xfstests> ltp/fsstress -d
/mnt/scratch-s 1370236858 -p 512 -n 8192&Hasn't reproduced after 10 minutes of running at ENOSPC here - how long does it take to reproduce? What storage hardware are you testing on? How many CPUs? RAM? ....
Quoted 5 lines
http://xfs.org/index.php/XFS_FAQ#Q:_What_information_should_I_include_when_reporting_a_problem.3F
Cheers,
Dave.
A 7-8 hours on spinning rust. This is my burn in test.
--Mark.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 47 lines · Mark Tinguely
Quoted 46 lines · Dave Chinner
Quoted 39 lines · Mark Tinguely
Quoted 24 lines · Namjae Jeon
From: Namjae Jeon<[email protected]>
Add support
FALLOC_FL_COLLAPSE_RANGEfor fallocate.Signed-off-by Namjae Jeon<[email protected]>Signed-off-by Ashish Sangwan<[email protected]>---
fs/xfs/xfs_bmap.c +16
-0+/* Check if we can merge 2 adjacent extents */ +if ((state&BMAP_LEFT_VALID )&& !(state&BMAP_LEFT_DELAY )&& + left.br_startoff + left.br_blockcount == startoff&& + left.br_startblock + left.br_blockcount == +xfs_bmbt_get_startblock (gotp)&& +xfs_bmbt_get_state (gotp) == left.br_state&& + left.br_blockcount +xfs_bmbt_get_blockcount (gotp)<= +MAXEXTLEN ) { + blockcount = + left.br_blockcount +xfs_bmbt_get_blockcount (gotp); + state |=BMAP_LEFT_CONTIG ; +xfs_iext_remove (ip, *current_ext,1 ,0 ); +XFS_IFORK_NEXT_SET (ip, whichfork, +XFS_IFORK_NEXTENTS (ip, whichfork) -1 ); + gotp =xfs_iext_get_ext (ifp, --*current_ext); + }fs/xfs/xfs_bmap.c error0: · line 5496
Quoted 10 lines
fs/xfs/xfs_bmap.c +10
-0+ +if (cur) { + error =xfs_bmbt_lookup_eq (cur, +xfs_bmbt_get_startoff (gotp), +xfs_bmbt_get_startblock (gotp), +xfs_bmbt_get_blockcount (gotp), + &i); +if (error) + goto del_cursor; +XFS_WANT_CORRUPTED_GOTO (i ==1 , del_cursor);I can reliably trigger this
XFS_WANT_CORRUPTED_GOTO()with a fsstress that fills the filesystem:Quoted 1 line
xfstests> ltp/fsstress -d
/mnt/scratch-s 1370236858 -p 512 -n 8192&Hasn't reproduced after 10 minutes of running at ENOSPC here - how long does it take to reproduce? What storage hardware are you testing on? How many CPUs? RAM? ....
Quoted 7 lines
Quoted 5 lines
http://xfs.org/index.php/XFS_FAQ#Q:_What_information_should_I_include_when_reporting_a_problem.3F
Cheers,
Dave.
A 7-8 hours on spinning rust. This is my burn in test.
Can you try to narrow the problem down? Otherwise it's going to be a case of looking for a needle in a haystack....
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 50 lines · Dave Chinner
Quoted 49 lines · Mark Tinguely
Quoted 48 lines · Dave Chinner
Quoted 39 lines · Mark Tinguely
Quoted 24 lines · Namjae Jeon
From: Namjae Jeon<[email protected]>
Add support
FALLOC_FL_COLLAPSE_RANGEfor fallocate.Signed-off-by Namjae Jeon<[email protected]>Signed-off-by Ashish Sangwan<[email protected]>---
fs/xfs/xfs_bmap.c +16
-0+/* Check if we can merge 2 adjacent extents */ +if ((state&BMAP_LEFT_VALID )&& !(state&BMAP_LEFT_DELAY )&& + left.br_startoff + left.br_blockcount == startoff&& + left.br_startblock + left.br_blockcount == +xfs_bmbt_get_startblock (gotp)&& +xfs_bmbt_get_state (gotp) == left.br_state&& + left.br_blockcount +xfs_bmbt_get_blockcount (gotp)<= +MAXEXTLEN ) { + blockcount = + left.br_blockcount +xfs_bmbt_get_blockcount (gotp); + state |=BMAP_LEFT_CONTIG ; +xfs_iext_remove (ip, *current_ext,1 ,0 ); +XFS_IFORK_NEXT_SET (ip, whichfork, +XFS_IFORK_NEXTENTS (ip, whichfork) -1 ); + gotp =xfs_iext_get_ext (ifp, --*current_ext); + }fs/xfs/xfs_bmap.c error0: · line 5496
Quoted 10 lines
fs/xfs/xfs_bmap.c +10
-0+ +if (cur) { + error =xfs_bmbt_lookup_eq (cur, +xfs_bmbt_get_startoff (gotp), +xfs_bmbt_get_startblock (gotp), +xfs_bmbt_get_blockcount (gotp), + &i); +if (error) + goto del_cursor; +XFS_WANT_CORRUPTED_GOTO (i ==1 , del_cursor);I can reliably trigger this
XFS_WANT_CORRUPTED_GOTO()with a fsstress that fills the filesystem:Quoted 1 line
xfstests> ltp/fsstress -d
/mnt/scratch-s 1370236858 -p 512 -n 8192&Hasn't reproduced after 10 minutes of running at ENOSPC here - how long does it take to reproduce? What storage hardware are you testing on? How many CPUs? RAM? ....
http://xfs.org/index.php/XFS_FAQ#Q:_What_information_should_I_include_when_reporting_a_problem.3F
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Cheers,
Dave.
A 7-8 hours on spinning rust. This is my burn in test.
Can you try to narrow the problem down? Otherwise it's going to be a case of looking for a needle in a haystack....
The VMs I've left this running on have now been doing so for almost 24 hours without triggering any issues. I'm really going to need a more refined reproducer for this to confirm it is a real problem and not a new machine burn-in issue...
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 54 lines · Dave Chinner
Quoted 53 lines · Mark Tinguely
Quoted 51 lines · Dave Chinner
Quoted 39 lines · Mark Tinguely
Quoted 24 lines · Namjae Jeon
From: Namjae Jeon<[email protected]>
Add support
FALLOC_FL_COLLAPSE_RANGEfor fallocate.Signed-off-by Namjae Jeon<[email protected]>Signed-off-by Ashish Sangwan<[email protected]>---
fs/xfs/xfs_bmap.c +16
-0+/* Check if we can merge 2 adjacent extents */ +if ((state &BMAP_LEFT_VALID ) && !(state &BMAP_LEFT_DELAY )&& + left.br_startoff + left.br_blockcount == startoff && + left.br_startblock + left.br_blockcount == +xfs_bmbt_get_startblock (gotp) && +xfs_bmbt_get_state (gotp) == left.br_state && + left.br_blockcount +xfs_bmbt_get_blockcount (gotp)<= +MAXEXTLEN ) { + blockcount = + left.br_blockcount +xfs_bmbt_get_blockcount (gotp); + state |=BMAP_LEFT_CONTIG ; +xfs_iext_remove (ip, *current_ext,1 ,0 ); +XFS_IFORK_NEXT_SET (ip, whichfork, +XFS_IFORK_NEXTENTS (ip, whichfork) -1 ); + gotp =xfs_iext_get_ext (ifp, --*current_ext); + }fs/xfs/xfs_bmap.c error0: · line 5496
Quoted 10 lines
fs/xfs/xfs_bmap.c +10
-0+ +if (cur) { + error =xfs_bmbt_lookup_eq (cur, +xfs_bmbt_get_startoff (gotp), +xfs_bmbt_get_startblock (gotp), +xfs_bmbt_get_blockcount (gotp), + &i); +if (error) + goto del_cursor; +XFS_WANT_CORRUPTED_GOTO (i ==1 , del_cursor);I can reliably trigger this
XFS_WANT_CORRUPTED_GOTO()with a fsstress that fills the filesystem:Quoted 1 line
xfstests> ltp/fsstress -d
/mnt/scratch-s 1370236858 -p 512 -n 8192&Hasn't reproduced after 10 minutes of running at ENOSPC here - how long does it take to reproduce? What storage hardware are you testing on? How many CPUs? RAM? ....
http://xfs.org/index.php/XFS_FAQ#Q:_What_information_should_I_include_when_reporting_a_problem.3F
Cheers,
Dave.
Quoted 8 lines
Quoted 1 line
A 7-8 hours on spinning rust. This is my burn in test.
Can you try to narrow the problem down? Otherwise it's going to be a case of looking for a needle in a haystack....
Cheers,
Dave.
Nod on the needle in a hay stack if it bmbt is really corrupt.
I am running fsstress from xfstests with the top commit 9b7f704, and I don't see any newer fsstress patches since then.
I moved the test to another box with a kdump that works on top of tree Linux and grabbed a vmcore. I grabbed a metadata dump of the filesystem after the ASSERT. That should give some idea of what inode/block it was looking up.
I sent email to Namjae when I first tripped over this problem in late April. No longer on the face of the earth and I can't look at this until the weekend.
--Mark.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 12 lines · Mark Tinguely
Quoted 5 lines · Dave Chinner
Quoted 1 line · Mark Tinguely
A 7-8 hours on spinning rust. This is my burn in test.
Can you try to narrow the problem down? Otherwise it's going to be a case of looking for a needle in a haystack....
Nod on the needle in a hay stack if it bmbt is really corrupt.
I am running fsstress from xfstests with the top commit 9b7f704, and I don't see any newer fsstress patches since then.
Quoted 8 lines
I moved the test to another box with a kdump that works on top of tree Linux and grabbed a vmcore. I grabbed a metadata dump of the filesystem after the ASSERT. That should give some idea of what inode/block it was looking up.
I sent email to Namjae when I first tripped over this problem in late April. No longer on the face of the earth and I can't look at this until the weekend.
No worries - it looks pretty hard to hit, so it's not something we urgently need to track down. Any time you can spare to try to narrow it down would be great!
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 22 lines · Dave Chinner
Quoted 12 lines · Mark Tinguely
Quoted 5 lines · Dave Chinner
Quoted 1 line · Mark Tinguely
A 7-8 hours on spinning rust. This is my burn in test.
Can you try to narrow the problem down? Otherwise it's going to be a case of looking for a needle in a haystack....
Nod on the needle in a hay stack if it bmbt is really corrupt.
I am running fsstress from xfstests with the top commit 9b7f704, and I don't see any newer fsstress patches since then.
Quoted 8 lines
I moved the test to another box with a kdump that works on top of tree Linux and grabbed a vmcore. I grabbed a metadata dump of the filesystem after the ASSERT. That should give some idea of what inode/block it was looking up.
I sent email to Namjae when I first tripped over this problem in late April. No longer on the face of the earth and I can't look at this until the weekend.
Quoted 7 lines
No worries - it looks pretty hard to hit, so it's not something we urgently need to track down. Any time you can spare to try to narrow it down would be great!
Cheers,
Dave.
The xfs_inode thinks there are 11 bmbt entries when there should only be 11:
i_df = {
if_bytes = 0xb0, <- here 11 entries 0x10 bytes long
if_real_bytes = 0x100,
if_broot = 0xffff88009f74c680,
if_broot_bytes = 0x28,
if_flags = 0x6,
if_u1 = {
if_extents = 0xffff88033c44a000, <-
if_ext_irec = 0xffff88033c44a000,
if_data = 0xffff88033c44a000 ""
},Looking at the if_extents[]:
crash> rd ffff88033c44a000 32
ffff88033c44a000: 8000000000000200 000000b601800021 ........!.......
ffff88033c44a010: 0000000000004400 000000449a000007 .D..........D...
ffff88033c44a020: 0000000000005200 000002f897e00004 .R..............
ffff88033c44a030: 8000000000005a00 000002f898600033 .Z......3.`.....
ffff88033c44a040: 000000000000c000 000002f89ec00001 ................
ffff88033c44a050: 0000000000015c00 000005fdfba00010 .\..............
ffff88033c44a060: 0000000000017c00 00000eab00400006 .|........@.....
ffff88033c44a070: 000000000001f800 00000ec752c00004 ...........R....
ffff88033c44a080: 0000000000020000 00000e8ae6800004 ................
ffff88033c44a090: 0000000000020800 00000e7167e00004 ...........gq...
ffff88033c44a0a0: 000000000002bfff ffffffc000a00001 ................
^^^^ bad ^^^^It appears that current_ext is 10 (11th entry).
The assert is on the bad entry.
xfs_db thinks there are 11 entries:
recs[1-11] = [startoff,startblock,blockcount,extentflag] 1:[1,372748,33,1] 2:[34,140496,18,0] 3:[52,1557619,53,1] 4:[105,1557672,27,0] 5:[132,1557699,51,1] 6:[183,1557750,1,0] 7:[261,3141597,16,0] 8:[277,7690242,6,0] 9:[339,7748246,4,0] 10:[343,7624500,4,0] 11:[347,7572287,4,0]
xfs_db> fsb 4262789xfs_db> type textxfs_db> p
000: 42 4d 41 50 00 00 00 0b ff ff ff ff ff ff ff ff BMAP............ 010: ff ff ff ff ff ff ff ff 80 00 00 00 00 00 02 00 ................ 020: 00 00 00 b6 01 80 00 21 00 00 00 00 00 00 44 00 ..............D. 030: 00 00 00 44 9a 00 00 12 80 00 00 00 00 00 68 00 ...D..........h. 040: 00 00 02 f8 8e 60 00 35 00 00 00 00 00 00 d2 00 .......5........ 050: 00 00 02 f8 95 00 00 1b 80 00 00 00 00 01 08 00 ................ 060: 00 00 02 f8 98 60 00 33 00 00 00 00 00 01 6e 00 .......3......n. 070: 00 00 02 f8 9e c0 00 01 00 00 00 00 00 02 0a 00 ................ 080: 00 00 05 fd fb a0 00 10 00 00 00 00 00 02 2a 00 ................ 090: 00 00 0e ab 00 40 00 06 00 00 00 00 00 02 a6 00 ................ 0a0: 00 00 0e c7 52 c0 00 04 00 00 00 00 00 02 ae 00 ....R........... 0b0: 00 00 0e 8a e6 80 00 04 00 00 00 00 00 02 b6 00 ................ 0c0: 00 00 0e 71 67 e0 00 04 00 00 00 00 00 00 00 00 ...qg........... 0d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
This xfs_db is before log replay, but it appears that the 3 extent is missing in the data fork, everything shifted up and a garbage entry in entry 11.
--Mark.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 5 lines · Mark Tinguely
The
xfs_inodethinks there are 11 bmbt entries when there should only be 11:i_df = { if_bytes = 0xb0, <- here 11 entries 0x10 bytes long
sorry bad editing when I could not do hex math. There are 11 entries, should be 11 entries, but we have one missing entry and one garbage entry.
--Mark.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 59 lines · Mark Tinguely
Quoted 22 lines · Dave Chinner
Quoted 12 lines · Mark Tinguely
Quoted 5 lines · Dave Chinner
Quoted 1 line · Mark Tinguely
A 7-8 hours on spinning rust. This is my burn in test.
Can you try to narrow the problem down? Otherwise it's going to be a case of looking for a needle in a haystack....
Nod on the needle in a hay stack if it bmbt is really corrupt.
I am running fsstress from xfstests with the top commit 9b7f704, and I don't see any newer fsstress patches since then.
Quoted 8 lines
I moved the test to another box with a kdump that works on top of tree Linux and grabbed a vmcore. I grabbed a metadata dump of the filesystem after the ASSERT. That should give some idea of what inode/block it was looking up.
I sent email to Namjae when I first tripped over this problem in late April. No longer on the face of the earth and I can't look at this until the weekend.
Quoted 7 lines
No worries - it looks pretty hard to hit, so it's not something we urgently need to track down. Any time you can spare to try to narrow it down would be great!
Cheers,
Dave.
The
xfs_inodethinks there are 11 bmbt entries when there should only be 11:i_df = { if_bytes = 0xb0, <- here 11 entries 0x10 bytes long if_real_bytes = 0x100, if_broot = 0xffff88009f74c680, if_broot_bytes = 0x28, if_flags = 0x6, if_u1 = { if_extents = 0xffff88033c44a000, <- if_ext_irec = 0xffff88033c44a000, if_data = 0xffff88033c44a000 "" },Looking at the if_extents[]:
crash> rd
ffff88033c44a00032ffff88033c44a000: 8000000000000200 000000b601800021 ........!....... ffff88033c44a010: 0000000000004400 000000449a000007 .D..........D... ffff88033c44a020: 0000000000005200 000002f897e00004 .R.............. ffff88033c44a030: 8000000000005a00 000002f898600033 .Z......3.`..... ffff88033c44a040: 000000000000c000 000002f89ec00001 ................ ffff88033c44a050: 0000000000015c00 000005fdfba00010 .\.............. ffff88033c44a060: 0000000000017c00 00000eab00400006 .|........@..... ffff88033c44a070: 000000000001f800 00000ec752c00004 ...........R.... ffff88033c44a080: 0000000000020000 00000e8ae6800004 ................ ffff88033c44a090: 0000000000020800 00000e7167e00004 ...........gq... ffff88033c44a0a0: 000000000002bfff ffffffc000a00001 ................ ^^^^ bad ^^^^
Quoted 2 lines
It appears that
current_extis 10 (11th entry).
The assert is on the bad entry.
I don't think that's bad - it looks like a NULL start block which means an in-memory extent. i.e. a delayed allocation block with a indirect reservation of 1 block and a length of ~0x40 blocks?
Quoted 27 lines
xfs_dbthinks there are 11 entries:recs[1-11] = [startoff,startblock,blockcount,extentflag] 1:[1,372748,33,1] 2:[34,140496,18,0] 3:[52,1557619,53,1] 4:[105,1557672,27,0] 5:[132,1557699,51,1] 6:[183,1557750,1,0] 7:[261,3141597,16,0] 8:[277,7690242,6,0] 9:[339,7748246,4,0] 10:[343,7624500,4,0] 11:[347,7572287,4,0]
xfs_db> fsb 4262789xfs_db> type textxfs_db> p000: 42 4d 41 50 00 00 00 0b ff ff ff ff ff ff ff ff BMAP............ 010: ff ff ff ff ff ff ff ff 80 00 00 00 00 00 02 00 ................ 020: 00 00 00 b6 01 80 00 21 00 00 00 00 00 00 44 00 ..............D. 030: 00 00 00 44 9a 00 00 12 80 00 00 00 00 00 68 00 ...D..........h. 040: 00 00 02 f8 8e 60 00 35 00 00 00 00 00 00 d2 00 .......5........ 050: 00 00 02 f8 95 00 00 1b 80 00 00 00 00 01 08 00 ................ 060: 00 00 02 f8 98 60 00 33 00 00 00 00 00 01 6e 00 .......3......n. 070: 00 00 02 f8 9e c0 00 01 00 00 00 00 00 02 0a 00 ................ 080: 00 00 05 fd fb a0 00 10 00 00 00 00 00 02 2a 00 ................ 090: 00 00 0e ab 00 40 00 06 00 00 00 00 00 02 a6 00 ................ 0a0: 00 00 0e c7 52 c0 00 04 00 00 00 00 00 02 ae 00 ....R........... 0b0: 00 00 0e 8a e6 80 00 04 00 00 00 00 00 02 b6 00 ................ 0c0: 00 00 0e 71 67 e0 00 04 00 00 00 00 00 00 00 00 ...qg........... 0d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
Quoted 3 lines
This
xfs_dbis before log replay, but it appears that the 3 extent is missing in the data fork, everything shifted up and a garbage entry in entry 11.
There's very few identical extents between those two lists - the first is the same, the second has the same start offset and block but is much shorted, and all the others are completely different.
So this is looking like a delalloc extent when the code is not expecting it?
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs