NFS: Use GFP_NOFS in nfs_direct_req_alloc
Subsystems (2)
PATCH 1/1 NFS: Use GFP_NOFS in nfs_direct_req_alloc
Don't dive into memory reclaim in the NFS direct I/O paths, otherwise we can deadlock.
Reported by: Wengang Wang <[email protected]>
---
Trond-
Thoughts?
fs/nfs/direct.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
fs/nfs/direct.c +1 -1
@@ -149,7 +149,7 @@ static inline struct nfs_direct_req *nfs_direct_req_alloc(void) {struct nfs_direct_req *dreq; - dreq =kmem_cache_alloc (nfs_direct_cachep,GFP_KERNEL ); + dreq =kmem_cache_alloc (nfs_direct_cachep,GFP_NOFS );if (!dreq)return NULL ;
A message that is not in the archive (sent off-list or not yet received): 20090908220230.7590.69833.stgit-RytpoXr2tKZ9HhUboXbp9zCvJB+x5qRC@public.gmane.org
Quoted 6 lines · Chuck Lever
Don't dive into memory reclaim in the NFS direct I/O paths, otherwise we can deadlock.
Reported by: Wengang Wang <[email protected]>
Fix-suggested-by Zach Brown <[email protected]>Signed-off-by Chuck Lever <[email protected]>
Wait... What??? How does an O_DIRECT read or write allocation deadlock with memory reclaim? Both the read and the write path call nfs_direct_req_alloc() before they pin any user pages in memory.
Trond
Quoted 27 lines
---
Trond-
Thoughts?
fs/nfs/direct.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)fs/nfs/direct.c +1
-2@@ -149,7 +149,7 @@ static inline struct nfs_direct_req *nfs_direct_req_alloc(void) {struct nfs_direct_req *dreq; - dreq =kmem_cache_alloc (nfs_direct_cachep,GFP_KERNEL ); + dreq =kmem_cache_alloc (nfs_direct_cachep,GFP_NOFS );if (!dreq)return NULL ; --To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com
A message that is not in the archive (sent off-list or not yet received): 1252449178.8099.64.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org
Quoted 11 lines · Trond Myklebust
Quoted 6 lines · Chuck Lever
Don't dive into memory reclaim in the NFS direct I/O paths, otherwise we can deadlock.
Reported by: Wengang Wang <[email protected]>
Fix-suggested-by Zach Brown <[email protected]>Signed-off-by Chuck Lever <[email protected]>Wait... What??? How does an
O_DIRECTread or write allocation deadlock with memory reclaim? Both the read and the write path callnfs_direct_req_alloc()before they pin any user pages in memory.
This may be an issue only for loopback mounts where the backing device is an NFS O_DIRECT file. This type of deadlock may not be able to happen in upstream kernels at this point.
Even so, it makes sense for this allocation to be consistent with similar allocations in the other NFS I/O paths.
Quoted 26 lines
Trond
Quoted 24 lines
---
Trond-
Thoughts?
fs/nfs/direct.c| 2 +-1 files changed, 1 insertions(+), 1 deletions(-)fs/nfs/direct.c +1
-1@@ -149,7 +149,7 @@ static inline struct nfs_direct_req *nfs_direct_req_alloc(void) {struct nfs_direct_req *dreq; - dreq =kmem_cache_alloc (nfs_direct_cachep,GFP_KERNEL ); + dreq =kmem_cache_alloc (nfs_direct_cachep,GFP_NOFS );if (!dreq)return NULL ;
Quoted 16 lines
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.htmlSignature · 10 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
Quoted 9 lines · Chuck Lever
Quoted 8 lines · Trond Myklebust
Quoted 6 lines · Chuck Lever
Don't dive into memory reclaim in the NFS direct I/O paths, otherwise we can deadlock.
Reported by: Wengang Wang <[email protected]>
Fix-suggested-by Zach Brown <[email protected]>Signed-off-by Chuck Lever <[email protected]>
Quoted 7 lines
Quoted 3 lines
Wait... What??? How does an
O_DIRECTread or write allocation deadlock with memory reclaim? Both the read and the write path callnfs_direct_req_alloc()before they pin any user pages in memory.This may be an issue only for loopback mounts where the backing device is an NFS
O_DIRECTfile. This type of deadlock may not be able to happen in upstream kernels at this point.
I don't see how that makes any difference whatsoever. If the backing device is a non-O_DIRECT file, then you have GFP_KERNEL allocation of the pages.
Anything that calls down into a filesystem on a read() or write() path had better not assume that it won't block.
Quoted 2 lines
Even so, it makes sense for this allocation to be consistent with similar allocations in the other NFS I/O paths.
I don't buy the 'symmetry' argument. The reason for the GFP_NOFS in the nfs_writedata_alloc() is that you have a deadlock when the VM calls ->writepages() in order to reclaim memory.
That is not the case here, and so this is not a symmetrical case.
Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com
A message that is not in the archive (sent off-list or not yet received): 1252451130.8099.81.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org
Quoted 18 lines · Trond Myklebust
Quoted 9 lines · Chuck Lever
Quoted 8 lines · Trond Myklebust
Quoted 6 lines · Chuck Lever
Don't dive into memory reclaim in the NFS direct I/O paths, otherwise we can deadlock.
Reported by: Wengang Wang <[email protected]>
Fix-suggested-by Zach Brown <[email protected]>Signed-off-by Chuck Lever <[email protected]>Quoted 7 lines
Quoted 3 lines
Wait... What??? How does an
O_DIRECTread or write allocation deadlock with memory reclaim? Both the read and the write path callnfs_direct_req_alloc()before they pin any user pages in memory.This may be an issue only for loopback mounts where the backing device is an NFS
O_DIRECTfile. This type of deadlock may not be able to happen in upstream kernels at this point.
Quoted 6 lines
I don't see how that makes any difference whatsoever. If the backing device is a non-O_DIRECT file, then you have
GFP_KERNELallocation of the pages.Anything that calls down into a filesystem on a
read()orwrite()path had better not assume that it won't block.
Basically we're treating an O_DIRECT file just like a block device. If the block I/O path blocks when a kernel file system calls in to do a memory reclaim, we're in dutch.
Quoted 7 lines
Quoted 2 lines
Even so, it makes sense for this allocation to be consistent with similar allocations in the other NFS I/O paths.
I don't buy the 'symmetry' argument. The reason for the
GFP_NOFSin thenfs_writedata_alloc()is that you have a deadlock when the VM calls ->writepages() in order to reclaim memory.
That is not the case here, and so this is not a symmetrical case.
That is precisely the case here, in fact. The upper file system is attempting to reclaim memory in the same kernel where the NFS client is trying to allocate with GFP_KERNEL.
Quoted 8 lines
Signature · 7 lines
-- Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
Quoted 26 lines · Chuck Lever
Quoted 25 lines · Trond Myklebust
Quoted 15 lines · Chuck Lever
Quoted 5 lines · Trond Myklebust
Quoted 4 lines · Chuck Lever
Don't dive into memory reclaim in the NFS direct I/O paths, otherwise
we can deadlock.Quoted 8 lines
Quoted 3 lines
Reported by: Wengang Wang <[email protected]>
Fix-suggested-by Zach Brown <[email protected]>Signed-off-by Chuck Lever <[email protected]>Wait... What??? How does an
O_DIRECTread or write allocation deadlock
with memory reclaim? Both the read and the write path callnfs_direct_req_alloc()before they pin any user pages in memory.Quoted 4 lines
This may be an issue only for loopback mounts where the backing device
is an NFSO_DIRECTfile. This type of deadlock may not be able to happen in upstream kernels at this point.I don't see how that makes any difference whatsoever. If the backing device is a non-O_DIRECT file, then you have
GFP_KERNELallocation of the pages.
Quoted 6 lines
Quoted 2 lines
Anything that calls down into a filesystem on a
read()orwrite()path had better not assume that it won't block.Basically we're treating an
O_DIRECTfile just like a block device. If the block I/O path blocks when a kernel file system calls in to do a memory reclaim, we're in dutch.
Without a lot more changelog context that explains what you are wanting to do, why it is relevant to NFS (and O_DIRECT in particular), and why you can't work around it in other ways (PF_MEMALLOC comes to mind), I'm not at all interested in applying this patch.
Quoted 9 lines
Quoted 8 lines
Quoted 2 lines
Even so, it makes sense for this allocation to be consistent with similar allocations in the other NFS I/O paths.
I don't buy the 'symmetry' argument. The reason for the
GFP_NOFSin thenfs_writedata_alloc()is that you have a deadlock when the VM calls ->writepages() in order to reclaim memory.
That is not the case here, and so this is not a symmetrical case.
Quoted 3 lines
That is precisely the case here, in fact. The upper file system is attempting to reclaim memory in the same kernel where the NFS client is trying to allocate with
GFP_KERNEL.
That's the "upper file system"'s problem, not ours... Stacking filesystems causes issues. Screwing over the existing users of the underlying filesystem is not a fix for those issues...
Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com
A message that is not in the archive (sent off-list or not yet received): 1252460233.5092.12.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org
Quoted 30 lines · Trond Myklebust
Quoted 29 lines · Chuck Lever
Quoted 27 lines · Trond Myklebust
Quoted 15 lines · Chuck Lever
Quoted 5 lines · Trond Myklebust
Quoted 4 lines · Chuck Lever
Don't dive into memory reclaim in the NFS direct I/O paths, otherwise
we can deadlock.Quoted 8 lines
Quoted 3 lines
Reported by: Wengang Wang <[email protected]>
Fix-suggested-by Zach Brown <[email protected]>Signed-off-by Chuck Lever <[email protected]>Wait... What??? How does an
O_DIRECTread or write allocation deadlock
with memory reclaim? Both the read and the write path callnfs_direct_req_alloc()before they pin any user pages in memory.Quoted 4 lines
This may be an issue only for loopback mounts where the backing device
is an NFSO_DIRECTfile. This type of deadlock may not be able to happen in upstream kernels at this point.I don't see how that makes any difference whatsoever. If the backing device is a non-O_DIRECT file, then you have
GFP_KERNELallocation of the pages.Anything that calls down into a filesystem on a
read()orwrite()path had better not assume that it won't block.
Quoted 8 lines
Quoted 3 lines
Basically we're treating an
O_DIRECTfile just like a block device. If the block I/O path blocks when a kernel file system calls in to do a memory reclaim, we're in dutch.Without a lot more changelog context that explains what you are wanting to do, why it is relevant to NFS (and
O_DIRECTin particular), and why you can't work around it in other ways (PF_MEMALLOCcomes to mind), I'm not at all interested in applying this patch.
I didn't ask you to apply it, I just asked for your thoughts.
We have a dm target that uses an NFS file as a backing device. It converts bios to NFS read and write requests using direct and async I/O. It's a loopback block device with a local file system residing in it.
(OK, so "loopback mount" was probably not a clear way to explain what is going on).
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 2 lines
Even so, it makes sense for this allocation to be consistent with similar allocations in the other NFS I/O paths.
I don't buy the 'symmetry' argument. The reason for the
GFP_NOFSin thenfs_writedata_alloc()is that you have a deadlock when the VM calls ->writepages() in order to reclaim memory.
That is not the case here, and so this is not a symmetrical case.
Quoted 7 lines
Quoted 3 lines
That is precisely the case here, in fact. The upper file system is attempting to reclaim memory in the same kernel where the NFS client is trying to allocate with
GFP_KERNEL.That's the "upper file system"'s problem, not ours... Stacking filesystems causes issues. Screwing over the existing users of the underlying filesystem is not a fix for those issues...
How does this change "screw over" the existing users of NFS O_DIRECT?
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
Quoted 11 lines · Chuck Lever
Quoted 8 lines · Trond Myklebust
Quoted 3 lines · Chuck Lever
That is precisely the case here, in fact. The upper file system is attempting to reclaim memory in the same kernel where the NFS client is trying to allocate with
GFP_KERNEL.That's the "upper file system"'s problem, not ours... Stacking filesystems causes issues. Screwing over the existing users of the underlying filesystem is not a fix for those issues...
How does this change "screw over" the existing users of NFS
O_DIRECT?
If they are low on memory, and call read() or write() on an O_DIRECT file, the kernel will fail to start the necessary memory reclaim. Given that by far the most common users of NFS O_DIRECT these days tend to be large databases with rather heavy memory requirements our code changes should rather be moving in the opposite direction w.r.t. use of GFP_NOFS.
Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com