generic/736: don't run it on tmpfs
Subsystems (2)
PATCH 1/1 generic/736: don't run it on tmpfs
We use offset_readdir for tmpfs, and every we call rename, the offset for the parent dir will increase by 1. So for tmpfs we will always fail since the infinite readdir.
--- tests/generic/736 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/generic/736 +1 -1
@@ -18,7 +18,7 @@ _cleanup() rm -fr $target_dir } -_supported_fs generic +_supported_fs generic ^tmpfs _require_test _require_test_program readdir-while-renames
Signature · 1 line
2.39.2
Quoted 4 lines · Yang Erkun
We use
offset_readdirfor tmpfs, and every we call rename, the offset for the parent dir will increase by 1. So for tmpfs we will always fail since the infinite readdir.
Having an infinite readdir sounds like a bug, or at least an inconvenience and surprising for users.
We had that problem in btrfs which affected users/applications, see:
https://lore.kernel.org/linux-btrfs/[email protected]/
which was surprising for them since every other filesystem they used/tested didn't have that problem.
Why not fix tmpfs?
Thanks.
Quoted 23 lines
Signed-off-by Yang Erkun <[email protected]>--- tests/generic/736 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tests/generic/736 +1
-2@@ -18,7 +18,7 @@ _cleanup() rm -fr $target_dir } -_supported_fs generic +_supported_fs generic ^tmpfs _require_test _require_test_program readdir-while-renames --2.39.2
Hi, All,
Sorry for the delay relay(something happened, and cannot use pc before...).
Quoted 10 lines · Filipe Manana
Quoted 4 lines · Yang Erkun
We use
offset_readdirfor tmpfs, and every we call rename, the offset for the parent dir will increase by 1. So for tmpfs we will always fail since the infinite readdir.Having an infinite readdir sounds like a bug, or at least an inconvenience and surprising for users.
We had that problem in btrfs which affected users/applications, see:
Quoted 5 lines
https://lore.kernel.org/linux-btrfs/[email protected]/
which was surprising for them since every other filesystem they used/tested didn't have that problem.
Why not fix tmpfs?
Thanks for all your advise, I will give a detail analysis first(maybe until last week I can do it), and after we give a conclusion about does this behavior a bug or something expected to occur, I will choose the next step!
Thanks again for all your advise!
Quoted 26 lines
Thanks.
Quoted 23 lines
Signed-off-by Yang Erkun <[email protected]>--- tests/generic/736 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tests/generic/736 +1
-2@@ -18,7 +18,7 @@ _cleanup() rm -fr $target_dir } -_supported_fs generic +_supported_fs generic ^tmpfs _require_test _require_test_program readdir-while-renames --2.39.2
Hi,
Quoted 18 lines · yangerkun
Hi, All,
Sorry for the delay
relay(something happened, and cannot use pc before...).Quoted 12 lines · Filipe Manana
Quoted 4 lines · Yang Erkun
We use
offset_readdirfor tmpfs, and every we call rename, the offset for the parent dir will increase by 1. So for tmpfs we will always fail since the infinite readdir.Having an infinite readdir sounds like a bug, or at least an inconvenience and surprising for users.
We had that problem in btrfs which affected users/applications, see:
Quoted 8 lines
Quoted 3 lines
which was surprising for them since every other filesystem they used/tested didn't have that problem.
Why not fix tmpfs?Thanks for all your advise, I will give a detail analysis first(maybe until last week I can do it), and after we give a conclusion about does this behavior a bug or something expected to occur, I will choose the next step!
The case generic/736 do something like below:
1. create 5000 files(1 2 3 ...) under one dir(testdir)
2. call readdir(man 3 readdir) once, and get entry
3. rename(entry, "TEMPFILE"), then rename("TMPFILE", entry)
4. loop 2~3, until readdir return nothing of we loop too many times(15000)
For tmpfs before a2e459555c5f("shmem: stable directory offsets"), every rename called, the new dentry will insert to d_subdirs *head* of parent dentry, and dcache_readdir won't reenter this dentry if we have already enter the dentry, so in step 4 we will break the test since readdir return nothing (I have try to change __d_move the insert to the "tail" of d_sub_dirs, problem can still happend).
But after commit a2e459555c5f("shmem: stable directory offsets"), simple_offset_rename will just add the new dentry to the maple tree of &SHMEM_I(inode)->dir_offsets->mt with the key always inc by 1(since simple_offset_add we will find free entry start with octx->newx_offset, so the entry freed in simple_offset_remove won't be found). And the same case upper will be break since we loop too many times(we can fall into infinite readdir without this break).
I prefer this is really a bug, and for the way to fix it, I think we can just use the same logic what 9b378f6ad48cf("btrfs: fix infinite directory reads") has did, introduce a last_index when we open the dir, and then readdir will not return the entry which index greater than the last index.
Looking forward to your comments!
Thanks,
Erkun.
Quoted 30 lines
Thanks again for all your advise!
Quoted 26 lines
Thanks.
Quoted 23 lines
Signed-off-by Yang Erkun <[email protected]>---
tests/generic/736 | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)tests/generic/736 +0
-0@@ -18,7 +18,7 @@ _cleanup()rm -fr $target_dir
}tests/generic/736 +1
-1-_supported_fs generic +_supported_fs generic ^tmpfs
_require_test
_require_test_programreaddir-while-renamesSignature · 1 line
2.39.2
Quoted 8 lines · yangerkun
But after commit
a2e459555c5f("shmem: stable directory offsets"),simple_offset_renamewill just add the new dentry to the maple tree of &SHMEM_I(inode)->dir_offsets->mt with the key always inc by 1(sincesimple_offset_addwe will find free entry start withoctx->newx_offset, so the entry freed insimple_offset_removewon't be found). And the same case upper will be break since we loop too many times(we can fall into infinite readdir without this break).
Quoted 6 lines
I prefer this is really a bug, and for the way to fix it, I think we can just use the same logic what 9b378f6ad48cf("btrfs: fix infinite directory reads") has did, introduce a
last_indexwhen we open the dir, and then readdir will not return the entry which index greater than the last index.Looking forward to your comments!
I agree to all of the above.
Quoted 9 lines · Christoph Hellwig
Quoted 8 lines · yangerkun
But after commit
a2e459555c5f("shmem: stable directory offsets"),simple_offset_renamewill just add the new dentry to the maple tree of &SHMEM_I(inode)->dir_offsets->mt with the key always inc by 1(sincesimple_offset_addwe will find free entry start withoctx->newx_offset, so the entry freed insimple_offset_removewon't be found). And the same case upper will be break since we loop too many times(we can fall into infinite readdir without this break).
Quoted 9 lines
Quoted 6 lines
I prefer this is really a bug, and for the way to fix it, I think we can just use the same logic what 9b378f6ad48cf("btrfs: fix infinite directory reads") has did, introduce a
last_indexwhen we open the dir, and then readdir will not return the entry which index greater than the last index.Looking forward to your comments!
I agree to all of the above.
Thanks, I will try to write a patch for this!
Quoted 38 lines · yangerkun
Hi,
Quoted 16 lines · yangerkun
Hi, All,
Sorry for the delayrelay(something happened, and cannot use pc before...).Quoted 12 lines · Filipe Manana
Quoted 4 lines · Yang Erkun
We use
offset_readdirfor tmpfs, and every we call rename, the offset for the parent dir will increase by 1. So for tmpfs we will always fail since the infinite readdir.Having an infinite readdir sounds like a bug, or at least an inconvenience and surprising for users.
We had that problem in btrfs which affected users/applications, see:Quoted 7 lines
Quoted 3 lines
which was surprising for them since every other filesystem they used/tested didn't have that problem.
Why not fix tmpfs?Thanks for all your advise, I will give a detail analysis first(maybe until last week I can do it), and after we give a conclusion about does this behavior a bug or something expected to occur, I will choose the next step!
The case generic/736 do something like below:
1. create 5000 files(1 2 3 ...) under one dir(testdir)
2. call readdir(man 3 readdir) once, and get entry
3.rename(entry, "TEMPFILE"), thenrename("TMPFILE", entry)
4. loop 2~3, until readdir return nothing of we loop too many times(15000)
Quoted 7 lines
For tmpfs before
a2e459555c5f("shmem: stable directory offsets"), every rename called, the new dentry will insert tod_subdirs*head* of parent dentry, anddcache_readdirwon't reenter this dentry if we have already enter the dentry, so in step 4 we will break the test since readdir return nothing (I have try to change__d_movethe insert to the "tail" ofd_sub_dirs, problem can still happend).But after commit
a2e459555c5f("shmem: stable directory offsets"),simple_offset_renamewill just add the new dentry to the maple tree of &SHMEM_I(inode)->dir_offsets->mt with the key always inc by 1(sincesimple_offset_addwe will find free entry start withoctx->newx_offset, so the entry freed insimple_offset_removewon't be found). And the same case upper will be break since we loop too many times(we can fall into infinite readdir without this break).I prefer this is really a bug, and for the way to fix it, I think we can just use the same logic what 9b378f6ad48cf("btrfs: fix infinite directory reads") has did, introduce a
last_indexwhen we open the dir, and then readdir will not return the entry which index greater than the last index.Looking forward to your comments!
Is this the same bug as https://bugzilla.kernel.org/show_bug.cgi?id=219094 ?
Quoted 28 lines
Thanks,
Erkun.Quoted 23 lines
Thanks again for all your advise!
Quoted 22 lines
Thanks.
Quoted 19 lines
Signed-off-by Yang Erkun <[email protected]>--- tests/generic/736 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tests/generic/736 +1
-1@@ -18,7 +18,7 @@ _cleanup() rm -fr $target_dir } -_supported_fs generic +_supported_fs generic ^tmpfs _require_test _require_test_program readdir-while-renames
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Signature · 1 line
2.39.2
--
Chuck Lever
Quoted 41 lines · Chuck Lever III
Quoted 41 lines · yangerkun
Hi,
Quoted 16 lines · yangerkun
Hi, All,
Sorry for the delayrelay(something happened, and cannot use pc before...).Quoted 12 lines · Filipe Manana
Quoted 4 lines · Yang Erkun
We use
offset_readdirfor tmpfs, and every we call rename, the offset for the parent dir will increase by 1. So for tmpfs we will always fail since the infinite readdir.Having an infinite readdir sounds like a bug, or at least an inconvenience and surprising for users.
We had that problem in btrfs which affected users/applications, see:Quoted 7 lines
Quoted 3 lines
which was surprising for them since every other filesystem they used/tested didn't have that problem.
Why not fix tmpfs?Thanks for all your advise, I will give a detail analysis first(maybe until last week I can do it), and after we give a conclusion about does this behavior a bug or something expected to occur, I will choose the next step!
The case generic/736 do something like below:
1. create 5000 files(1 2 3 ...) under one dir(testdir)
2. call readdir(man 3 readdir) once, and get entry
3.rename(entry, "TEMPFILE"), thenrename("TMPFILE", entry)
4. loop 2~3, until readdir return nothing of we loop too many times(15000)For tmpfs before
a2e459555c5f("shmem: stable directory offsets"), every rename called, the new dentry will insert tod_subdirs*head* of parent dentry, anddcache_readdirwon't reenter this dentry if we have already enter the dentry, so in step 4 we will break the test since readdir return nothing (I have try to change__d_movethe insert to the "tail" ofd_sub_dirs, problem can still happend).
Quoted 7 lines
Quoted 5 lines
But after commit
a2e459555c5f("shmem: stable directory offsets"),simple_offset_renamewill just add the new dentry to the maple tree of &SHMEM_I(inode)->dir_offsets->mt with the key always inc by 1(sincesimple_offset_addwe will find free entry start withoctx->newx_offset, so the entry freed insimple_offset_removewon't be found). And the same case upper will be break since we loop too many times(we can fall into infinite readdir without this break).I prefer this is really a bug, and for the way to fix it, I think we can just use the same logic what 9b378f6ad48cf("btrfs: fix infinite directory reads") has did, introduce a
last_indexwhen we open the dir, and then readdir will not return the entry which index greater than the last index.Looking forward to your comments!
Is this the same bug as https://bugzilla.kernel.org/show_bug.cgi?id=219094 ?
Yes, my last comment there explicitly points to this thread.
Quoted 39 lines
Quoted 30 lines
Thanks,
Erkun.Quoted 23 lines
Thanks again for all your advise!
Quoted 22 lines
Thanks.
Quoted 19 lines
Signed-off-by Yang Erkun <[email protected]>--- tests/generic/736 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tests/generic/736 +1
-1@@ -18,7 +18,7 @@ _cleanup() rm -fr $target_dir } -_supported_fs generic +_supported_fs generic ^tmpfs _require_test _require_test_program readdir-while-renamesQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
--
2.39.2--
Chuck Lever
Quoted 40 lines · Chuck Lever III
Quoted 40 lines · yangerkun
Hi,
Quoted 16 lines · yangerkun
Hi, All,
Sorry for the delayrelay(something happened, and cannot use pc before...).Quoted 12 lines · Filipe Manana
Quoted 4 lines · Yang Erkun
We use
offset_readdirfor tmpfs, and every we call rename, the offset for the parent dir will increase by 1. So for tmpfs we will always fail since the infinite readdir.Having an infinite readdir sounds like a bug, or at least an inconvenience and surprising for users.
We had that problem in btrfs which affected users/applications, see:Quoted 7 lines
Quoted 3 lines
which was surprising for them since every other filesystem they used/tested didn't have that problem.
Why not fix tmpfs?Thanks for all your advise, I will give a detail analysis first(maybe until last week I can do it), and after we give a conclusion about does this behavior a bug or something expected to occur, I will choose the next step!
The case generic/736 do something like below:
1. create 5000 files(1 2 3 ...) under one dir(testdir)
2. call readdir(man 3 readdir) once, and get entry
3.rename(entry, "TEMPFILE"), thenrename("TMPFILE", entry)
4. loop 2~3, until readdir return nothing of we loop too many times(15000)For tmpfs before
a2e459555c5f("shmem: stable directory offsets"), every rename called, the new dentry will insert tod_subdirs*head* of parent dentry, anddcache_readdirwon't reenter this dentry if we have already enter the dentry, so in step 4 we will break the test since readdir return nothing (I have try to change__d_movethe insert to the "tail" ofd_sub_dirs, problem can still happend).
Quoted 7 lines
Quoted 5 lines
But after commit
a2e459555c5f("shmem: stable directory offsets"),simple_offset_renamewill just add the new dentry to the maple tree of &SHMEM_I(inode)->dir_offsets->mt with the key always inc by 1(sincesimple_offset_addwe will find free entry start withoctx->newx_offset, so the entry freed insimple_offset_removewon't be found). And the same case upper will be break since we loop too many times(we can fall into infinite readdir without this break).I prefer this is really a bug, and for the way to fix it, I think we can just use the same logic what 9b378f6ad48cf("btrfs: fix infinite directory reads") has did, introduce a
last_indexwhen we open the dir, and then readdir will not return the entry which index greater than the last index.Looking forward to your comments!
Is this the same bug as https://bugzilla.kernel.org/show_bug.cgi?id=219094 ?
Yes.
Quoted 39 lines
Quoted 30 lines
Thanks,
Erkun.Quoted 23 lines
Thanks again for all your advise!
Quoted 22 lines
Thanks.
Quoted 19 lines
Signed-off-by Yang Erkun <[email protected]>--- tests/generic/736 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tests/generic/736 +1
-1@@ -18,7 +18,7 @@ _cleanup() rm -fr $target_dir } -_supported_fs generic +_supported_fs generic ^tmpfs _require_test _require_test_program readdir-while-renamesQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Signature · 1 line
2.39.2--
Chuck Lever
Quoted 53 lines · yangerkun
Hi,
Quoted 18 lines · yangerkun
Hi, All,
Sorry for the delay
relay(something happened, and cannot use pc before...).Quoted 12 lines · Filipe Manana
Quoted 4 lines · Yang Erkun
We use
offset_readdirfor tmpfs, and every we call rename, the offset for the parent dir will increase by 1. So for tmpfs we will always fail since the infinite readdir.Having an infinite readdir sounds like a bug, or at least an inconvenience and surprising for users.
We had that problem in btrfs which affected users/applications, see:Quoted 8 lines
Quoted 3 lines
which was surprising for them since every other filesystem they used/tested didn't have that problem.
Why not fix tmpfs?Thanks for all your advise, I will give a detail analysis first(maybe until last week I can do it), and after we give a conclusion about does this behavior a bug or something expected to occur, I will choose the next step!
The case generic/736 do something like below:
1. create 5000 files(1 2 3 ...) under one dir(testdir)
2. call readdir(man 3 readdir) once, and get entry
3.rename(entry, "TEMPFILE"), thenrename("TMPFILE", entry)
4. loop 2~3, until readdir return nothing of we loop too many times(15000)For tmpfs before
a2e459555c5f("shmem: stable directory offsets"), every rename called, the new dentry will insert tod_subdirs*head* of parent dentry, anddcache_readdirwon't reenter this dentry if we have already enter the dentry, so in step 4 we will break the test since readdir return nothing (I have try to change__d_movethe insert to the "tail" ofd_sub_dirs, problem can still happend).But after commit
a2e459555c5f("shmem: stable directory offsets"),simple_offset_renamewill just add the new dentry to the maple tree of &SHMEM_I(inode)->dir_offsets->mt with the key always inc by 1(sincesimple_offset_addwe will find free entry start withoctx->newx_offset, so the entry freed insimple_offset_removewon't be found). And the same case upper will be break since we loop too many times(we can fall into infinite readdir without this break).
Quoted 5 lines
I prefer this is really a bug, and for the way to fix it, I think we can just use the same logic what 9b378f6ad48cf("btrfs: fix infinite directory reads") has did, introduce a
last_indexwhen we open the dir, and then readdir will not return the entry which index greater than the last index.
Don't forget to reset the index to whatever is the current last index when rewind() is called.
We ended up with that bug in btrfs later, see:
Anyway, if the same mistake is made, it would be caught by a test case for fstests I submitted after:
Quoted 38 lines
Looking forward to your comments!
Thanks,
Erkun.Quoted 30 lines
Thanks again for all your advise!
Quoted 26 lines
Thanks.
Quoted 23 lines
Signed-off-by Yang Erkun <[email protected]>--- tests/generic/736 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tests/generic/736 +1
-2@@ -18,7 +18,7 @@ _cleanup() rm -fr $target_dir } -_supported_fs generic +_supported_fs generic ^tmpfs _require_test _require_test_program readdir-while-renames --2.39.2
Quoted 60 lines · Filipe Manana
Quoted 53 lines · yangerkun
Hi,
Quoted 18 lines · yangerkun
Hi, All,
Sorry for the delay
relay(something happened, and cannot use pc before...).Quoted 12 lines · Filipe Manana
Quoted 4 lines · Yang Erkun
We use
offset_readdirfor tmpfs, and every we call rename, the offset for the parent dir will increase by 1. So for tmpfs we will always fail since the infinite readdir.Having an infinite readdir sounds like a bug, or at least an inconvenience and surprising for users.
We had that problem in btrfs which affected users/applications, see:Quoted 8 lines
Quoted 3 lines
which was surprising for them since every other filesystem they used/tested didn't have that problem.
Why not fix tmpfs?Thanks for all your advise, I will give a detail analysis first(maybe until last week I can do it), and after we give a conclusion about does this behavior a bug or something expected to occur, I will choose the next step!
The case generic/736 do something like below:
1. create 5000 files(1 2 3 ...) under one dir(testdir)
2. call readdir(man 3 readdir) once, and get entry
3.rename(entry, "TEMPFILE"), thenrename("TMPFILE", entry)
4. loop 2~3, until readdir return nothing of we loop too many times(15000)For tmpfs before
a2e459555c5f("shmem: stable directory offsets"), every rename called, the new dentry will insert tod_subdirs*head* of parent dentry, anddcache_readdirwon't reenter this dentry if we have already enter the dentry, so in step 4 we will break the test since readdir return nothing (I have try to change__d_movethe insert to the "tail" ofd_sub_dirs, problem can still happend).But after commit
a2e459555c5f("shmem: stable directory offsets"),simple_offset_renamewill just add the new dentry to the maple tree of &SHMEM_I(inode)->dir_offsets->mt with the key always inc by 1(sincesimple_offset_addwe will find free entry start withoctx->newx_offset, so the entry freed insimple_offset_removewon't be found). And the same case upper will be break since we loop too many times(we can fall into infinite readdir without this break).Quoted 5 lines
I prefer this is really a bug, and for the way to fix it, I think we can just use the same logic what 9b378f6ad48cf("btrfs: fix infinite directory reads") has did, introduce a
last_indexwhen we open the dir, and then readdir will not return the entry which index greater than the last index.
Quoted 5 lines
Don't forget to reset the index to whatever is the current last index when
rewind()is called.
We ended up with that bug in btrfs later, see:
Thanks for your reminder, will change offset_dir_llseek too!
Quoted 46 lines
Anyway, if the same mistake is made, it would be caught by a test case for fstests I submitted after:
Quoted 38 lines
Looking forward to your comments!
Thanks,
Erkun.Quoted 30 lines
Thanks again for all your advise!
Quoted 26 lines
Thanks.
Quoted 23 lines
Signed-off-by Yang Erkun <[email protected]>--- tests/generic/736 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tests/generic/736 +1
-2@@ -18,7 +18,7 @@ _cleanup() rm -fr $target_dir } -_supported_fs generic +_supported_fs generic ^tmpfs _require_test _require_test_program readdir-while-renames --2.39.2
Quoted 3 lines · Yang Erkun
We use
offset_readdirfor tmpfs, and every we call rename, the offset for the parent dir will increase by 1. So for tmpfs we will always fail since the infinite readdir.
This honestly sounds like a bug in tmpfs, so maybe we should discuss the behavior first?
If the changes goes in please write a comment documenting it in the test case.
Quoted 11 lines · Christoph Hellwig
Quoted 3 lines · Yang Erkun
We use
offset_readdirfor tmpfs, and every we call rename, the offset for the parent dir will increase by 1. So for tmpfs we will always fail since the infinite readdir.This honestly sounds like a bug in tmpfs, so maybe we should discuss the behavior first?
Agreed, sounds like there should be some root cause analysis before the tests are altered.
Is this problem addressed in recent kernels?
--
Chuck Lever