Btrfs: break out of orphan cleanup if we can't make progress V2
PATCH 1/1 Btrfs: break out of orphan cleanup if we can't make progress V2
I noticed while running xfstests 83 that if we didn't have enough space to delete our inode the orphan cleanup would just loop. This is because it keeps finding the same orphan item and keeps trying to kill it but can't because we don't get an error back from iput for deleting the inode. So keep track of the last guy we tried to kill, if it's the same as the one we're trying to kill currently we know we are having problems and can just error out. I don't have a way to test this so look hard and make sure it's right. Thanks,
---V1->V2: set last_objectid properly
fs/btrfs/inode.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
fs/btrfs/inode.c +11 -0
@@ -2230,6 +2230,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root)struct btrfs_key key, found_key;struct btrfs_trans_handle *trans;struct inode *inode; +u64 last_objectid =0 ;int ret =0 , nr_unlink =0 , nr_truncate =0 ;if (cmpxchg (&root->orphan_cleanup_state,0 ,ORPHAN_CLEANUP_STARTED ))
@@ -2281,6 +2282,16 @@ int btrfs_orphan_cleanup(struct btrfs_root *root)* crossing root thing. we store the inode number in the * offset of the orphan item. */ + +if (found_key.offset == last_objectid) { +printk (KERN_ERR "btrfs: Error removing orphan entry, " +"stopping orphan cleanup\n" ); + ret = -EINVAL ; + goto out; + } + + last_objectid = found_key.offset; + found_key.objectid = found_key.offset; found_key.type =BTRFS_INODE_ITEM_KEY ; found_key.offset =0 ;
Signature · 1 line
1.7.5.2
Quoted 1 line · Josef Bacik
I noticed while running xfstests 83 that if we didn't have enough spa=
ce to
Quoted 1 line
delete our inode the orphan cleanup would just loop. =A0This is becau=
se it keeps
Quoted 1 line
finding the same orphan item and keeps trying to kill it but can't be=
cause we
Quoted 1 line
don't get an error back from iput for deleting the inode. =A0So keep =
track of the
Quoted 1 line
last guy we tried to kill, if it's the same as the one we're trying t=
o kill
Quoted 1 line
currently we know we are having problems and can just error out. =A0I=
don't have a
fs/btrfs/inode.c int btrfs_orphan_cleanup(struct btrfs_root *roo=
Quoted 14 lines
way to test this so look hard and make sure it's right. =A0Thanks,
Signed-off-by Josef Bacik <[email protected]>---
V1->V2: setlast_objectidproperly=A0fs/btrfs/inode.c | =A0 11 +++++++++++ =A01 files changed, 11 insertions(+), 0 deletions(-)
fs/btrfs/inode.c +0
-0@@ -2230,6 +2230,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *roo=
t)
Quoted 7 lines
fs/btrfs/inode.c +1
-0=A0 =A0 =A0 =A0struct btrfs_key key, found_key; =A0 =A0 =A0 =A0struct btrfs_trans_handle *trans; =A0 =A0 =A0 =A0struct inode *inode; + =A0 =A0 =A0 u64 last_objectid =3D 0; =A0 =A0 =A0 =A0int ret =3D 0, nr_unlink =3D 0, nr_truncate =3D 0;=A0 =A0 =A0 =A0if (cmpxchg(&root->orphan_cleanup_state, 0, ORPHAN_CLE=
ANUP_STARTED))
fs/btrfs/inode.c int btrfs_orphan_cleanup(struct btrfs_root *ro=
Quoted 1 line
fs/btrfs/inode.c +0
-0@@ -2281,6 +2282,16 @@ int btrfs_orphan_cleanup(struct btrfs_root *ro=
ot)
Quoted 1 line
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 * crossing root thing. =A0we store th=
e inode number in the
Quoted 4 lines
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 * offset of the orphan item. =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 */
+
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (found_key.offset =3D=3D last_object=
id) {
Quoted 1 line
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 printk(KERN_ERR "btrfs:=
Error removing orphan entry, "
Quoted 1 line
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"stoppin=
g orphan cleanup\n");
Quoted 7 lines
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ret =3D
-EINVAL;
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto out;
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 }fs/btrfs/inode.c +3
-0+ + =A0 =A0 =A0 =A0 =A0 =A0 =A0 last_objectid =3D found_key.offset; +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0found_key.objectid =3D found_key.offse=
t;
Quoted 1 line
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0found_key.type =3D BTRFS_INODE_ITEM_KE=
Y;
Quoted 4 lines
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0found_key.offset =3D 0; --
1.7.5.2
Just in case it gets lost in the shuffle between github and git.kernel.org, and also for the benefit of those testing Chris Mason's integration-test branch on github, please note that version 1 of this patch is still in Chris' integration-test branch, as well as in Josef's github kernel repos (master and for-chris branch only, the unstable branch has this version of the patch).
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" = in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 1 line · Mitch Harder
On Tue, Oct 4, 2011 at 10:54 AM, Josef Bacik <[email protected]> wrote=
:
Quoted 1 line
Quoted 1 line
I noticed while running xfstests 83 that if we didn't have enough s=
pace to
Quoted 1 line
Quoted 1 line
delete our inode the orphan cleanup would just loop. =A0This is bec=
ause it keeps
Quoted 1 line
Quoted 1 line
finding the same orphan item and keeps trying to kill it but can't =
because we
Quoted 1 line
Quoted 1 line
don't get an error back from iput for deleting the inode. =A0So kee=
p track of the
Quoted 1 line
Quoted 1 line
last guy we tried to kill, if it's the same as the one we're trying=
to kill
Quoted 1 line
Quoted 1 line
currently we know we are having problems and can just error out. =A0=
I don't have a
Quoted 6 lines
Quoted 6 lines
way to test this so look hard and make sure it's right. =A0Thanks,
Signed-off-by Josef Bacik <[email protected]>---
V1->V2: setlast_objectidproperly
Quoted 8 lines
fs/btrfs/inode.c int btrfs_orphan_cleanup(struct btrfs_root *r=
Quoted 8 lines
=A0fs/btrfs/inode.c | =A0 11 +++++++++++ =A01 files changed, 11 insertions(+), 0 deletions(-)
fs/btrfs/inode.c +0
-0@@ -2230,6 +2230,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *r=
oot)
Quoted 7 lines
Quoted 7 lines
fs/btrfs/inode.c +1
-0=A0 =A0 =A0 =A0struct btrfs_key key, found_key; =A0 =A0 =A0 =A0struct btrfs_trans_handle *trans; =A0 =A0 =A0 =A0struct inode *inode; + =A0 =A0 =A0 u64 last_objectid =3D 0; =A0 =A0 =A0 =A0int ret =3D 0, nr_unlink =3D 0, nr_truncate =3D 0;=A0 =A0 =A0 =A0if (cmpxchg(&root->orphan_cleanup_state, 0, ORPHAN_C=
LEANUP_STARTED))
Quoted 1 line
fs/btrfs/inode.c int btrfs_orphan_cleanup(struct btrfs_root *=
Quoted 1 line
fs/btrfs/inode.c +0
-0@@ -2281,6 +2282,16 @@ int btrfs_orphan_cleanup(struct btrfs_root *=
root)
Quoted 1 line
Quoted 1 line
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 * crossing root thing. =A0we store =
the inode number in the
Quoted 4 lines
Quoted 4 lines
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 * offset of the orphan item. =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 */
+
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (found_key.offset =3D=3D last_obje=
ctid) {
Quoted 1 line
Quoted 1 line
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 printk(KERN_ERR "btrf=
s: Error removing orphan entry, "
Quoted 1 line
Quoted 1 line
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"stopp=
ing orphan cleanup\n");
Quoted 7 lines
Quoted 7 lines
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ret =3D
-EINVAL;
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto out;
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 }fs/btrfs/inode.c +3
-0+ + =A0 =A0 =A0 =A0 =A0 =A0 =A0 last_objectid =3D found_key.offset; +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0found_key.objectid =3D found_key.off=
set;
Quoted 1 line
Quoted 1 line
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0found_key.type =3D BTRFS_INODE_ITEM_=
KEY;
Quoted 11 lines
Quoted 4 lines
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0found_key.offset =3D 0; --
1.7.5.2=20
Just in case it gets lost in the shuffle between github and git.kernel.org, and also for the benefit of those testing Chris Mason's integration-test branch on github, please note that version 1 of this patch is still in Chris' integration-test branch, as well as in Josef's github kernel repos (master and for-chris branch only, the unstable branch has this version of the patch).
I've migrated back to git.kernel.org btw so the right version should be=
in
git.kernel.org. Would it be usefull if I keep up the github tree as we= ll?
Thanks,
Josef
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" = in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 2 lines · Josef Bacik
Quoted 1 line · Mitch Harder
On Tue, Oct 4, 2011 at 10:54 AM, Josef Bacik <[email protected]> wrot=
e:
Quoted 1 line
Quoted 1 line
Quoted 1 line
I noticed while running xfstests 83 that if we didn't have enough =
space to
Quoted 1 line
Quoted 1 line
Quoted 1 line
delete our inode the orphan cleanup would just loop. =A0This is be=
cause it keeps
Quoted 1 line
Quoted 1 line
Quoted 1 line
finding the same orphan item and keeps trying to kill it but can't=
because we
Quoted 1 line
Quoted 1 line
Quoted 1 line
don't get an error back from iput for deleting the inode. =A0So ke=
ep track of the
Quoted 1 line
Quoted 1 line
Quoted 1 line
last guy we tried to kill, if it's the same as the one we're tryin=
g to kill
Quoted 1 line
Quoted 1 line
Quoted 1 line
currently we know we are having problems and can just error out. =A0=
I don't have a
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
way to test this so look hard and make sure it's right. =A0Thanks,
Signed-off-by Josef Bacik <[email protected]>---
V1->V2: setlast_objectidproperly
Quoted 8 lines
Quoted 8 lines
fs/btrfs/inode.c int btrfs_orphan_cleanup(struct btrfs_root *=
Quoted 8 lines
=A0fs/btrfs/inode.c | =A0 11 +++++++++++ =A01 files changed, 11 insertions(+), 0 deletions(-)
fs/btrfs/inode.c +0
-0@@ -2230,6 +2230,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *=
root)
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
fs/btrfs/inode.c +1
-0=A0 =A0 =A0 =A0struct btrfs_key key, found_key; =A0 =A0 =A0 =A0struct btrfs_trans_handle *trans; =A0 =A0 =A0 =A0struct inode *inode; + =A0 =A0 =A0 u64 last_objectid =3D 0; =A0 =A0 =A0 =A0int ret =3D 0, nr_unlink =3D 0, nr_truncate =3D 0;=A0 =A0 =A0 =A0if (cmpxchg(&root->orphan_cleanup_state, 0, ORPHAN_=
CLEANUP_STARTED))
Quoted 1 line
Quoted 1 line
fs/btrfs/inode.c int btrfs_orphan_cleanup(struct btrfs_root =
Quoted 1 line
fs/btrfs/inode.c +0
-0@@ -2281,6 +2282,16 @@ int btrfs_orphan_cleanup(struct btrfs_root =
*root)
Quoted 1 line
Quoted 1 line
Quoted 1 line
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 * crossing root thing. =A0we store=
the inode number in the
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 * offset of the orphan item. =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 */
+
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (found_key.offset =3D=3D last_obj=
ectid) {
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 printk(KERN_ERR "btr=
fs: Error removing orphan entry, "
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"stop=
ping orphan cleanup\n");
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ret =3D
-EINVAL;
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto out;
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 }fs/btrfs/inode.c +3
-0+ + =A0 =A0 =A0 =A0 =A0 =A0 =A0 last_objectid =3D found_key.offset; +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0found_key.objectid =3D found_key.of=
fset;
Quoted 1 line
Quoted 1 line
Quoted 1 line
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0found_key.type =3D BTRFS_INODE_ITEM=
_KEY;
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0found_key.offset =3D 0; --
1.7.5.2Just in case it gets lost in the shuffle between github and git.kernel.org, and also for the benefit of those testing Chris Mason's integration-test branch on github, please note that version =
1
Quoted 2 lines
Quoted 2 lines
of this patch is still in Chris' integration-test branch, as well as in Josef's github kernel repos (master and for-chris branch only, th=
e
Quoted 3 lines
Quoted 1 line
unstable branch has this version of the patch).
I've migrated back to git.kernel.org btw so the right version should =
be in
Quoted 1 line
git.kernel.org. =A0Would it be usefull if I keep up the github tree a=
s well?
Quoted 4 lines
Thanks,
Josef
As far as I'm concerned, maintaining multiple public trees isn't necess= ary.
I just wanted to make sure this patch wasn't lost in the shuffle. --
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" = in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html