nfsd: allow reaping files that are still under writeback
Subsystems (2)
Jeff Layton
maintainerPATCH 1/1 nfsd: allow reaping files that are still under writeback
There's no reason to delay reaping an nfsd_file just because its underlying inode is still under writeback. nfsd just relies on client activity or the local flusher threads to do writeback.
Holding the file open does nothing to facilitate that, nor does it help with tracking errors. Just allow it to close and let the kernel do writeback as it normally would.
--- fs/nfsd/filecache.c | 22 ---------------------- 1 file changed, 22 deletions(-)
fs/nfsd/filecache.c +0 -22
@@ -296,19 +296,6 @@ nfsd_file_free(struct nfsd_file *nf)call_rcu (&nf->nf_rcu, nfsd_file_slab_free); } -static bool -nfsd_file_check_writeback (struct nfsd_file *nf) -{ -struct file *file = nf->nf_file; -struct address_space *mapping; - -if (!file || !(file->f_mode &FMODE_WRITE )) -return false; - mapping = file->f_mapping; -return mapping_tagged (mapping,PAGECACHE_TAG_DIRTY ) || -mapping_tagged (mapping,PAGECACHE_TAG_WRITEBACK ); -} -static bool nfsd_file_lru_add (struct nfsd_file *nf) {set_bit (NFSD_FILE_REFERENCED , &nf->nf_flags);
@@ -438,15 +425,6 @@ nfsd_file_lru_cb(struct list_head *item, struct list_lru_one *lru,/* We should only be dealing with GC entries here */ WARN_ON_ONCE (!test_bit (NFSD_FILE_GC , &nf->nf_flags)); -/* -* Don't throw out files that are still undergoing I/O or -* that have uncleared errors pending. -*/ -if (nfsd_file_check_writeback (nf)) { -trace_nfsd_file_gc_writeback (nf); -return LRU_SKIP ; - } -/* If it was recently added to the list, skip it */ if (test_and_clear_bit (NFSD_FILE_REFERENCED , &nf->nf_flags)) {trace_nfsd_file_gc_referenced (nf);
Signature · 1 line
2.39.1
Chuck Lever III
AppliedQuoted 8 lines · Jeff Layton
There's no reason to delay reaping an
nfsd_filejust because its underlying inode is still under writeback. nfsd just relies on client activity or the local flusher threads to do writeback.
Quoted 5 lines
Holding the file open does nothing to facilitate that, nor does it help with tracking errors. Just allow it to close and let the kernel do writeback as it normally would.
Signed-off-by Jeff Layton <[email protected]>
Thanks! Applied to topic-filecache-cleanups.
Quoted 47 lines
---
fs/nfsd/filecache.c| 22 ----------------------1 file changed, 22 deletions(-)fs/nfsd/filecache.c +0
-22@@ -296,19 +296,6 @@ nfsd_file_free(struct nfsd_file *nf)call_rcu (&nf->nf_rcu, nfsd_file_slab_free); } -static bool -nfsd_file_check_writeback (struct nfsd_file *nf) -{ -struct file *file = nf->nf_file; -struct address_space *mapping; - -if (!file || !(file->f_mode &FMODE_WRITE )) -return false; - mapping = file->f_mapping; -return mapping_tagged (mapping,PAGECACHE_TAG_DIRTY ) || -mapping_tagged (mapping,PAGECACHE_TAG_WRITEBACK ); -} -static bool nfsd_file_lru_add (struct nfsd_file *nf) {set_bit (NFSD_FILE_REFERENCED , &nf->nf_flags);@@ -438,15 +425,6 @@ nfsd_file_lru_cb(struct list_head *item, struct list_lru_one *lru,/* We should only be dealing with GC entries here */ WARN_ON_ONCE (!test_bit (NFSD_FILE_GC , &nf->nf_flags)); -/* -* Don't throw out files that are still undergoing I/O or -* that have uncleared errors pending. -*/ -if (nfsd_file_check_writeback (nf)) { -trace_nfsd_file_gc_writeback (nf); -return LRU_SKIP ; - } -/* If it was recently added to the list, skip it */ if (test_and_clear_bit (NFSD_FILE_REFERENCED , &nf->nf_flags)) {trace_nfsd_file_gc_referenced (nf);Signature · 1 line
2.39.1
--
Chuck Lever
Trond Myklebust
maintainerQuoted 64 lines · Chuck Lever III
Quoted 10 lines
On Feb 13, 2023, at 3:23 PM, Jeff Layton <[email protected]> wrote:
There's no reason to delay reaping an
nfsd_filejust because its underlying inode is still under writeback. nfsd just relies on client
activity or the local flusher threads to do writeback.Quoted 6 lines
Holding the file open does nothing to facilitate that, nor does it help
with tracking errors. Just allow it to close and let the kernel do writeback as it normally would.Signed-off-by Jeff Layton <[email protected]>Thanks! Applied to topic-filecache-cleanups.
Quoted 44 lines
---
fs/nfsd/filecache.c| 22 ----------------------1 file changed, 22 deletions(-)fs/nfsd/filecache.c +0
-22@@ -296,19 +296,6 @@ nfsd_file_free(struct nfsd_file *nf) call_rcu(&nf->nf_rcu, nfsd_file_slab_free); } -static bool -nfsd_file_check_writeback (struct nfsd_file *nf) -{ - struct file *file = nf->nf_file; - struct address_space *mapping; - - if (!file || !(file->f_mode & FMODE_WRITE)) - return false; - mapping = file->f_mapping; - return mapping_tagged(mapping, PAGECACHE_TAG_DIRTY) || - mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK); -} -static bool nfsd_file_lru_add (struct nfsd_file *nf) { set_bit(NFSD_FILE_REFERENCED, &nf->nf_flags);@@ -438,15 +425,6 @@ nfsd_file_lru_cb(struct list_head *item,struct list_lru_one *lru, /* We should only be dealing with GC entries here */ WARN_ON_ONCE(!test_bit(NFSD_FILE_GC, &nf->nf_flags)); - /* - * Don't throw out files that are still undergoing I/O or - * that have uncleared errors pending. - */ - if (nfsd_file_check_writeback(nf)) { - trace_nfsd_file_gc_writeback(nf); - return LRU_SKIP; - } - /* If it was recently added to the list, skip it */if (test_and_clear_bit(NFSD_FILE_REFERENCED, &nf-
Quoted 11 lines
Quoted 5 lines
Quoted 1 line
nf_flags)) {trace_nfsd_file_gc_referenced(nf);
Signature · 1 line
2.39.1--
Chuck Lever
Wait... There is a good reason for wanting to do this in the case of NFS re-exports, since close() is a very expensive operation if the file has dirty data.
Signature · 3 lines
Trond Myklebust Linux NFS client maintainer, Hammerspace [email protected]
Quoted 81 lines · Trond Myklebust
Quoted 64 lines · Chuck Lever III
Quoted 10 lines
On Feb 13, 2023, at 3:23 PM, Jeff Layton <[email protected]> wrote:
There's no reason to delay reaping an
nfsd_filejust because its underlying inode is still under writeback. nfsd just relies on client
activity or the local flusher threads to do writeback.Quoted 6 lines
Holding the file open does nothing to facilitate that, nor does it help
with tracking errors. Just allow it to close and let the kernel do writeback as it normally would.Signed-off-by Jeff Layton <[email protected]>Thanks! Applied to topic-filecache-cleanups.
Quoted 44 lines
---
fs/nfsd/filecache.c| 22 ----------------------1 file changed, 22 deletions(-)fs/nfsd/filecache.c +0
-22@@ -296,19 +296,6 @@ nfsd_file_free(struct nfsd_file *nf)call_rcu (&nf->nf_rcu, nfsd_file_slab_free); } -static bool -nfsd_file_check_writeback (struct nfsd_file *nf) -{ -struct file *file = nf->nf_file; -struct address_space *mapping; - -if (!file || !(file->f_mode &FMODE_WRITE )) -return false; - mapping = file->f_mapping; -return mapping_tagged (mapping,PAGECACHE_TAG_DIRTY ) || -mapping_tagged (mapping,PAGECACHE_TAG_WRITEBACK ); -} -static bool nfsd_file_lru_add (struct nfsd_file *nf) {set_bit (NFSD_FILE_REFERENCED , &nf->nf_flags);@@ -438,15 +425,6 @@ nfsd_file_lru_cb(struct list_head *item,struct list_lru_one *lru,/* We should only be dealing with GC entries here */ WARN_ON_ONCE(!test_bit(NFSD_FILE_GC, &nf->nf_flags)); -/* -* Don't throw out files that are still undergoing I/O or -* that have uncleared errors pending. -*/ -if (nfsd_file_check_writeback (nf)) { -trace_nfsd_file_gc_writeback (nf); -return LRU_SKIP ; - } -/* If it was recently added to the list, skip it */ if (test_and_clear_bit(NFSD_FILE_REFERENCED, &nf-Quoted 11 lines
Quoted 5 lines
Quoted 1 line
nf_flags)) {trace_nfsd_file_gc_referenced(nf);Signature · 1 line
2.39.1--
Chuck Lever
Quoted 3 lines
Wait... There is a good reason for wanting to do this in the case of NFS re-exports, since
close()is a very expensive operation if the file has dirty data.
Then perhaps skipping these files can be gated on an EXPORT_OP flag?
--
Chuck Lever
Trond Myklebust
maintainerQuoted 87 lines · Chuck Lever III
Quoted 87 lines
On Feb 14, 2023, at 10:00 AM, Trond Myklebust <[email protected]> wrote:
Quoted 80 lines · Chuck Lever III
Quoted 11 lines
On Feb 13, 2023, at 3:23 PM, Jeff Layton <[email protected]> wrote:
There's no reason to delay reaping an
nfsd_filejust because its
underlying inode is still under writeback. nfsd just relies on client
activity or the local flusher threads to do writeback.Quoted 8 lines
Holding the file open does nothing to facilitate that, nor does it
help
with tracking errors. Just allow it to close and let the kernel do
writeback as it normally would.Signed-off-by Jeff Layton <[email protected]>Thanks! Applied to topic-filecache-cleanups.
Quoted 46 lines
---
fs/nfsd/filecache.c| 22 ----------------------1 file changed, 22 deletions(-)fs/nfsd/filecache.c +0
-13@@ -296,19 +296,6 @@ nfsd_file_free(struct nfsd_file *nf) call_rcu(&nf->nf_rcu, nfsd_file_slab_free); } -static bool -nfsd_file_check_writeback (struct nfsd_file *nf) -{ - struct file *file = nf->nf_file; - struct address_space *mapping; - - if (!file || !(file->f_mode & FMODE_WRITE)) - return false; - mapping = file->f_mapping; - return mapping_tagged(mapping, PAGECACHE_TAG_DIRTY) || - mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK); -} -static bool nfsd_file_lru_add (struct nfsd_file *nf) {
set_bit(NFSD_FILE_REFERENCED, &nf->nf_flags);fs/nfsd/filecache.c +0
-2@@ -438,15 +425,6 @@ nfsd_file_lru_cb(struct list_head *item,struct list_lru_one *lru, /* We should only be dealing with GC entries here */ WARN_ON_ONCE(!test_bit(NFSD_FILE_GC, &nf->nf_flags)); - /* -* Don't throw out files that are still undergoing I/O or
- * that have uncleared errors pending.
- */
- if (nfsd_file_check_writeback(nf)) {
-trace_nfsd_file_gc_writeback(nf); - returnLRU_SKIP;
- }
-
/* If it was recently added to the list, skip it */ if (test_and_clear_bit(NFSD_FILE_REFERENCED, &nf-Quoted 5 lines
Quoted 1 line
nf_flags)) {
trace_nfsd_file_gc_referenced(nf);Signature · 1 line
2.39.1--
Chuck Lever
Quoted 7 lines
Quoted 5 lines
Wait... There is a good reason for wanting to do this in the case of
NFS re-exports, sinceclose()is a very expensive operation if the file
has dirty data.Then perhaps skipping these files can be gated on an
EXPORT_OPflag?
That would work.
Signature · 3 lines
Trond Myklebust Linux NFS client maintainer, Hammerspace [email protected]
Jeff Layton
maintainerQuoted 77 lines · Trond Myklebust
Quoted 64 lines · Chuck Lever III
Quoted 10 lines
On Feb 13, 2023, at 3:23 PM, Jeff Layton <[email protected]> wrote:
There's no reason to delay reaping an
nfsd_filejust because its underlying inode is still under writeback. nfsd just relies on client
activity or the local flusher threads to do writeback.Quoted 6 lines
Holding the file open does nothing to facilitate that, nor does it help
with tracking errors. Just allow it to close and let the kernel do writeback as it normally would.Signed-off-by Jeff Layton <[email protected]>Thanks! Applied to topic-filecache-cleanups.
Quoted 44 lines
---
fs/nfsd/filecache.c| 22 ----------------------1 file changed, 22 deletions(-)fs/nfsd/filecache.c +0
-22@@ -296,19 +296,6 @@ nfsd_file_free(struct nfsd_file *nf) call_rcu(&nf->nf_rcu, nfsd_file_slab_free); } -static bool -nfsd_file_check_writeback (struct nfsd_file *nf) -{ - struct file *file = nf->nf_file; - struct address_space *mapping; - - if (!file || !(file->f_mode & FMODE_WRITE)) - return false; - mapping = file->f_mapping; - return mapping_tagged(mapping, PAGECACHE_TAG_DIRTY) || - mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK); -} -static bool nfsd_file_lru_add (struct nfsd_file *nf) { set_bit(NFSD_FILE_REFERENCED, &nf->nf_flags);@@ -438,15 +425,6 @@ nfsd_file_lru_cb(struct list_head *item,struct list_lru_one *lru, /* We should only be dealing with GC entries here */ WARN_ON_ONCE(!test_bit(NFSD_FILE_GC, &nf->nf_flags)); - /* - * Don't throw out files that are still undergoing I/O or - * that have uncleared errors pending. - */ - if (nfsd_file_check_writeback(nf)) { - trace_nfsd_file_gc_writeback(nf); - return LRU_SKIP; - } - /* If it was recently added to the list, skip it */if (test_and_clear_bit(NFSD_FILE_REFERENCED, &nf-
Quoted 11 lines
Quoted 5 lines
Quoted 1 line
nf_flags)) {trace_nfsd_file_gc_referenced(nf);
Signature · 1 line
2.39.1--
Chuck Lever
Quoted 4 lines
Wait... There is a good reason for wanting to do this in the case of NFS re-exports, since
close()is a very expensive operation if the file has dirty data.
Fair enough. What if we added a new EXPORT_OP_FLUSH_ON_CLOSE flag that filesystems could set in the export_operations? Then we could make this behavior conditional on that being set?
Signature · 1 line
Jeff Layton <[email protected]>
Trond Myklebust
maintainerQuoted 90 lines · Jeff Layton
Quoted 82 lines · Trond Myklebust
Quoted 69 lines · Chuck Lever III
Quoted 11 lines
On Feb 13, 2023, at 3:23 PM, Jeff Layton <[email protected]> wrote:
There's no reason to delay reaping an
nfsd_filejust because its
underlying inode is still under writeback. nfsd just relies on client
activity or the local flusher threads to do writeback.Quoted 8 lines
Holding the file open does nothing to facilitate that, nor does it
help
with tracking errors. Just allow it to close and let the kernel do
writeback as it normally would.Signed-off-by Jeff Layton <[email protected]>Thanks! Applied to topic-filecache-cleanups.
Quoted 46 lines
---
fs/nfsd/filecache.c| 22 ----------------------1 file changed, 22 deletions(-)fs/nfsd/filecache.c +0
-13@@ -296,19 +296,6 @@ nfsd_file_free(struct nfsd_file *nf) call_rcu(&nf->nf_rcu, nfsd_file_slab_free); } -static bool -nfsd_file_check_writeback (struct nfsd_file *nf) -{ - struct file *file = nf->nf_file; - struct address_space *mapping; - - if (!file || !(file->f_mode & FMODE_WRITE)) - return false; - mapping = file->f_mapping; - return mapping_tagged(mapping, PAGECACHE_TAG_DIRTY) || - mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK); -} -static bool nfsd_file_lru_add (struct nfsd_file *nf) {set_bit(NFSD_FILE_REFERENCED,
&nf->nf_flags);fs/nfsd/filecache.c +0
-2@@ -438,15 +425,6 @@ nfsd_file_lru_cb(struct list_head *item,struct list_lru_one *lru, /* We should only be dealing with GC entries here */ WARN_ON_ONCE(!test_bit(NFSD_FILE_GC, &nf->nf_flags)); - /* -* Don't throw out files that are still undergoing I/O or
- * that have uncleared errors pending.
- */
- if (nfsd_file_check_writeback(nf)) {
- trace_nfsd_file_gc_writeback(nf); - returnLRU_SKIP;
- }
-
/* If it was recently added to the list, skip it */ if (test_and_clear_bit(NFSD_FILE_REFERENCED, &nf-Quoted 11 lines
Quoted 5 lines
Quoted 1 line
nf_flags)) {trace_nfsd_file_gc_referenced(nf);
Signature · 1 line
2.39.1--
Chuck LeverQuoted 6 lines
Wait... There is a good reason for wanting to do this in the case of
NFS re-exports, sinceclose()is a very expensive operation if the file
has dirty data.
Quoted 5 lines
Fair enough. What if we added a new
EXPORT_OP_FLUSH_ON_CLOSEflag that
filesystems could set in theexport_operations? Then we could make this
behavior conditional on that being set?
Sure.
Signature · 3 lines
Trond Myklebust Linux NFS client maintainer, Hammerspace [email protected]