NFS: Fix a bug in nfs_fscache_release_page()
Subsystems (2)
PATCH 1/2 NFS: Fix a bug in nfs_fscache_release_page()
Not having an fscache cookie is perfectly valid if the user didn't mount with the fscache option.
This patch fixes http://bugzilla.kernel.org/show_bug.cgi?id=15234
--- fs/nfs/fscache.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
fs/nfs/fscache.c +3 -3
@@ -355,11 +355,11 @@ void nfs_fscache_reset_inode_cookie(struct inode *inode)int nfs_fscache_release_page (struct page *page,gfp_t gfp) {struct nfs_inode *nfsi =NFS_I (page->mapping->host); -struct fscache_cookie *cookie = nfsi->fscache; - -BUG_ON (!cookie);if (PageFsCache (page)) { +struct fscache_cookie *cookie = nfsi->fscache; + +BUG_ON (!cookie);dfprintk (FSCACHE ,"NFS: fscache releasepage (0x%p/0x%p/0x%p)\n" , cookie, page, nfsi);
Signature · 1 line
1.6.6
PATCH 2/2 NFS: Fix the mapping of the NFSERR_SERVERFAULT error
It was recently pointed out that the NFSERR_SERVERFAULT error, which is designed to inform the user of a serious internal error on the server, was being mapped to an error value that is internal to the kernel.
This patch maps it to the error EREMOTEIO, which is exported to userland through errno.h.
--- fs/nfs/mount_clnt.c | 2 +- fs/nfs/nfs2xdr.c | 2 +- fs/nfs/nfs4xdr.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-)
fs/nfs/mount_clnt.c +1 -1
@@ -120,7 +120,7 @@ static struct { { .status = MNT3ERR_INVAL, .errno = -EINVAL, }, { .status = MNT3ERR_NAMETOOLONG, .errno = -ENAMETOOLONG, }, { .status = MNT3ERR_NOTSUPP, .errno = -ENOTSUPP, }, - { .status = MNT3ERR_SERVERFAULT, .errno = -ESERVERFAULT, }, + { .status = MNT3ERR_SERVERFAULT, .errno = -EREMOTEIO, }, }; struct mountres {
fs/nfs/nfs2xdr.c +1 -1
@@ -699,7 +699,7 @@ static struct { { NFSERR_BAD_COOKIE, -EBADCOOKIE }, { NFSERR_NOTSUPP, -ENOTSUPP }, { NFSERR_TOOSMALL, -ETOOSMALL }, - { NFSERR_SERVERFAULT, -ESERVERFAULT }, + { NFSERR_SERVERFAULT, -EREMOTEIO }, { NFSERR_BADTYPE, -EBADTYPE }, { NFSERR_JUKEBOX, -EJUKEBOX }, { -1, -EIO }
fs/nfs/nfs4xdr.c +3 -3
@@ -4631,7 +4631,7 @@ static int decode_sequence(struct xdr_stream *xdr,* If the server returns different values for sessionID, slotID or * sequence number, the server is looney tunes. */ - status = -ESERVERFAULT ; + status = -EREMOTEIO ;if (memcmp (id.data, res->sr_session->sess_id.data,NFS4_MAX_SESSIONID_LEN )) {
@@ -5774,7 +5774,7 @@ static struct { { NFS4ERR_BAD_COOKIE, -EBADCOOKIE }, { NFS4ERR_NOTSUPP, -ENOTSUPP }, { NFS4ERR_TOOSMALL, -ETOOSMALL }, - { NFS4ERR_SERVERFAULT, -ESERVERFAULT }, + { NFS4ERR_SERVERFAULT, -EREMOTEIO }, { NFS4ERR_BADTYPE, -EBADTYPE }, { NFS4ERR_LOCKED, -EAGAIN }, { NFS4ERR_SYMLINK, -ELOOP },
@@ -5801,7 +5801,7 @@ nfs4_stat_to_errno(int stat) }if (stat <=10000 || stat >10100 ) {/* The server is looney tunes. */ -return -ESERVERFAULT ; +return -EREMOTEIO ; }/* If we cannot translate the error, the recovery routines should * handle it.
Signature · 1 line
1.6.6
Re: [PATCH 2/2] NFS: Fix the mapping of the NFSERR_SERVERFAULT error
Quoted 20 lines · Trond Myklebust
It was recently pointed out that the
NFSERR_SERVERFAULTerror, which is designed to inform the user of a serious internal error on the server, was being mapped to an error value that is internal to the kernel.This patch maps it to the error EREMOTEIO, which is exported to userland through
errno.h.Signed-off-by Trond Myklebust<[email protected]>--- fs/nfs/mount_clnt.c | 2 +- fs/nfs/nfs2xdr.c | 2 +- fs/nfs/nfs4xdr.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-)fs/nfs/mount_clnt.c +0
-0
fs/nfs/mount_clnt.c static struct { · line 126
Quoted 8 lines
fs/nfs/mount_clnt.c +1
-1@@ -120,7 +120,7 @@ static struct { { .status = MNT3ERR_INVAL, .errno = -EINVAL, }, { .status = MNT3ERR_NAMETOOLONG, .errno = -ENAMETOOLONG, }, { .status = MNT3ERR_NOTSUPP, .errno = -ENOTSUPP, }, - { .status = MNT3ERR_SERVERFAULT, .errno = -ESERVERFAULT, }, + { .status = MNT3ERR_SERVERFAULT, .errno = -EREMOTEIO, }, }; struct mountres {
The decode_status() and decode_fhs_status() functions return -EACCES if they don't recognize the server's error code. Should they return -EREMOTEIO instead?
Otherwise, looks good.
Quoted 44 lines
fs/nfs/nfs2xdr.c +1
-1@@ -699,7 +699,7 @@ static struct { { NFSERR_BAD_COOKIE, -EBADCOOKIE }, { NFSERR_NOTSUPP, -ENOTSUPP }, { NFSERR_TOOSMALL, -ETOOSMALL }, - { NFSERR_SERVERFAULT, -ESERVERFAULT }, + { NFSERR_SERVERFAULT, -EREMOTEIO }, { NFSERR_BADTYPE, -EBADTYPE }, { NFSERR_JUKEBOX, -EJUKEBOX }, { -1, -EIO }fs/nfs/nfs4xdr.c +3
-3@@ -4631,7 +4631,7 @@ static int decode_sequence(struct xdr_stream *xdr,* If the server returns different values for sessionID, slotID or * sequence number, the server is looney tunes. */ - status = -ESERVERFAULT ; + status = -EREMOTEIO ;if (memcmp (id.data, res->sr_session->sess_id.data,NFS4_MAX_SESSIONID_LEN )) {@@ -5774,7 +5774,7 @@ static struct { { NFS4ERR_BAD_COOKIE, -EBADCOOKIE }, { NFS4ERR_NOTSUPP, -ENOTSUPP }, { NFS4ERR_TOOSMALL, -ETOOSMALL }, - { NFS4ERR_SERVERFAULT, -ESERVERFAULT }, + { NFS4ERR_SERVERFAULT, -EREMOTEIO }, { NFS4ERR_BADTYPE, -EBADTYPE }, { NFS4ERR_LOCKED, -EAGAIN }, { NFS4ERR_SYMLINK, -ELOOP },@@ -5801,7 +5801,7 @@ nfs4_stat_to_errno(int stat) }if (stat<=10000 || stat>10100 ) {/* The server is looney tunes. */ -return -ESERVERFAULT ; +return -EREMOTEIO ; }/* If we cannot translate the error, the recovery routines should * handle it.
Signature · 1 line
chuck[dot]lever[at]oracle[dot]com
Re: [PATCH 2/2] NFS: Fix the mapping of the NFSERR_SERVERFAULT error
Quoted 28 lines · Chuck Lever
Quoted 27 lines · Trond Myklebust
It was recently pointed out that the
NFSERR_SERVERFAULTerror, which is designed to inform the user of a serious internal error on the server, was being mapped to an error value that is internal to the kernel.This patch maps it to the error EREMOTEIO, which is exported to userland through
errno.h.Signed-off-by Trond Myklebust<[email protected]>--- fs/nfs/mount_clnt.c | 2 +- fs/nfs/nfs2xdr.c | 2 +- fs/nfs/nfs4xdr.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-)fs/nfs/mount_clnt.c +1
-1@@ -120,7 +120,7 @@ static struct { { .status = MNT3ERR_INVAL, .errno = -EINVAL, }, { .status = MNT3ERR_NAMETOOLONG, .errno = -ENAMETOOLONG, }, { .status = MNT3ERR_NOTSUPP, .errno = -ENOTSUPP, }, - { .status = MNT3ERR_SERVERFAULT, .errno = -ESERVERFAULT, }, + { .status = MNT3ERR_SERVERFAULT, .errno = -EREMOTEIO, }, };
Quoted 5 lines
fs/nfs/mount_clnt.c static struct { · line 126
Quoted 1 line
fs/nfs/mount_clnt.c +0
-0struct mountres {The
decode_status()anddecode_fhs_status()functions return-EACCESif they don't recognize the server's error code. Should they return-EREMOTEIOinstead?
It might possibly be a bit more enlightening to the user, but that would be a separate patch. I wouldn't see that fix as being particularly
critical: EACCES is a valid error code that can be returned to userland.
Cheers
Trond
Quoted 20 lines · Trond Myklebust
Not having an fscache cookie is perfectly valid if the user didn't mount with the fscache option.
This patch fixes http://bugzilla.kernel.org/show_bug.cgi?id=15234
Signed-off-by Trond Myklebust <[email protected]>--- fs/nfs/fscache.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)fs/nfs/fscache.c +0
-1@@ -355,11 +355,11 @@ void nfs_fscache_reset_inode_cookie(struct inode *inode)int nfs_fscache_release_page (struct page *page,gfp_t gfp) {struct nfs_inode *nfsi =NFS_I (page->mapping->host); -struct fscache_cookie *cookie = nfsi->fscache;
fs/nfs/fscache.c void nfs_fscache_reset_inode_cookie(struct inode *inode) · line 365
Quoted 10 lines
fs/nfs/fscache.c +3
-2- -BUG_ON (!cookie);if (PageFsCache (page)) { +struct fscache_cookie *cookie = nfsi->fscache; + +BUG_ON (!cookie);dfprintk (FSCACHE ,"NFS: fscache releasepage (0x%p/0x%p/0x%p)\n" , cookie, page, nfsi);
There are only two callers for nfs_fscache_release_page() - nfs_release_page() and nfs_migrate_page(). nfs_migrate_page already does this:
if (PageFsCache(page))
nfs_fscache_release_page(page, GFP_KERNEL);and the assumption in nfs_release_page() is that the page should have either PG_private set or PG_fscache set and nfs_fscache_release_page gets called only if PG_private is not set.
I think the idea is that nfs_fscache_release_page should not get called if fsc option is not used. So it appears to me this patch is fixing the symptom not the actual issue. Perhaps, this the assumption in nfs_release_page is wrong or the PageFsCache() check should be moved to nfs_release_page?
Thanks,
Signature · 1 line
Suresh Jayaraman
Quoted 36 lines · Suresh Jayaraman
Quoted 20 lines · Trond Myklebust
Not having an fscache cookie is perfectly valid if the user didn't mount with the fscache option.
This patch fixes http://bugzilla.kernel.org/show_bug.cgi?id=15234
Signed-off-by Trond Myklebust <[email protected]>--- fs/nfs/fscache.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)fs/nfs/fscache.c +0
-1@@ -355,11 +355,11 @@ void nfs_fscache_reset_inode_cookie(struct inode *inode)int nfs_fscache_release_page (struct page *page,gfp_t gfp) {struct nfs_inode *nfsi =NFS_I (page->mapping->host); -struct fscache_cookie *cookie = nfsi->fscache;fs/nfs/fscache.c void nfs_fscache_reset_inode_cookie(struct inode *inode) · line 365
Quoted 10 lines
fs/nfs/fscache.c +3
-2- -BUG_ON (!cookie);if (PageFsCache (page)) { +struct fscache_cookie *cookie = nfsi->fscache; + +BUG_ON (!cookie);dfprintk (FSCACHE ,"NFS: fscache releasepage (0x%p/0x%p/0x%p)\n" , cookie, page, nfsi);There are only two callers for
nfs_fscache_release_page()-nfs_release_page()andnfs_migrate_page().nfs_migrate_pagealready does this:
Quoted 6 lines
if (PageFsCache(page)) nfs_fscache_release_page(page, GFP_KERNEL);and the assumption in
nfs_release_page()is that the page should have eitherPG_privateset orPG_fscacheset andnfs_fscache_release_pagegets called only ifPG_privateis not set.
...or if it gets cleared.
Quoted 5 lines
I think the idea is that
nfs_fscache_release_pageshould not get called if fsc option is not used. So it appears to me this patch is fixing the symptom not the actual issue. Perhaps, this the assumption innfs_release_pageis wrong or thePageFsCache()check should be moved tonfs_release_page?
No. We should rather get rid of the redundant check for PageFsCache() in nfs_migrate_page. PageFsCache() is particular to fscache, so the test belongs in the fscache code.
Trond
Quoted 5 lines · Trond Myklebust
Quoted 4 lines · Suresh Jayaraman
There are only two callers for
nfs_fscache_release_page()-nfs_release_page()andnfs_migrate_page().nfs_migrate_pagealready does this:
Quoted 8 lines
Quoted 6 lines
if (PageFsCache(page)) nfs_fscache_release_page(page, GFP_KERNEL);and the assumption in
nfs_release_page()is that the page should have eitherPG_privateset orPG_fscacheset andnfs_fscache_release_pagegets called only ifPG_privateis not set....or if it gets cleared.
To be more precise, even before we put call to nfs_wb_page() in nfs_release_page(), it was possible for the PG_private bit to be set when doing the test in shrink_page_list(), but for an outstanding commit operation to complete before the second test in nfs_release_page.
In this case, nfs_fscache_release_page would get called with neither PG_private nor PG_fscache being set, and the Oops could occur.
Quoted 9 lines
Quoted 5 lines
I think the idea is that
nfs_fscache_release_pageshould not get called if fsc option is not used. So it appears to me this patch is fixing the symptom not the actual issue. Perhaps, this the assumption innfs_release_pageis wrong or thePageFsCache()check should be moved tonfs_release_page?No. We should rather get rid of the redundant check for
PageFsCache()innfs_migrate_page.PageFsCache()is particular to fscache, so the test belongs in the fscache code.
I've added a cleanup patch (which will not go to [email protected]) to do this.
Trond
Quoted 9 lines · Trond Myklebust
Quoted 8 lines · Trond Myklebust
Quoted 7 lines · Suresh Jayaraman
There are only two callers for
nfs_fscache_release_page()-nfs_release_page()andnfs_migrate_page().nfs_migrate_pagealready does this:if (PageFsCache(page)) nfs_fscache_release_page(page, GFP_KERNEL);
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
and the assumption in
nfs_release_page()is that the page should have eitherPG_privateset orPG_fscacheset andnfs_fscache_release_pagegets called only ifPG_privateis not set....or if it gets cleared.
To be more precise, even before we put call to
nfs_wb_page()innfs_release_page(), it was possible for thePG_privatebit to be set
Yes, I have seen a similar bug report before we added nfs_wb_page on a 2.6.32 kernel too.
Quoted 6 lines
when doing the test in
shrink_page_list(), but for an outstanding commit operation to complete before the second test innfs_release_page.In this case,
nfs_fscache_release_pagewould get called with neitherPG_privatenorPG_fscachebeing set, and the Oops could occur.
We seem to ensure that we're holding a page lock in try_to_release_page. Even if the outstanding commit is complete by the time we are in nfs_releage_page, page flags should not have been modified, right?
Quoted 9 lines
Quoted 9 lines
Quoted 5 lines
I think the idea is that
nfs_fscache_release_pageshould not get called if fsc option is not used. So it appears to me this patch is fixing the symptom not the actual issue. Perhaps, this the assumption innfs_release_pageis wrong or thePageFsCache()check should be moved tonfs_release_page?No. We should rather get rid of the redundant check for
PageFsCache()innfs_migrate_page.PageFsCache()is particular to fscache, so the test belongs in the fscache code.
yes, make sense.
Thanks,
Signature · 1 line
Suresh Jayaraman
Quoted 3 lines · Suresh Jayaraman
We seem to ensure that we're holding a page lock in
try_to_release_page. Even if the outstanding commit is complete by the time we are innfs_releage_page, page flags should not have been modified, right?
No. PG_private may be cleared while another process is holding the page lock (just like PG_writeback may).
Once cleared, PG_private cannot be set again without grabbing the page lock.
Trond
Quoted 11 lines · Trond Myklebust
Quoted 3 lines · Suresh Jayaraman
We seem to ensure that we're holding a page lock in
try_to_release_page. Even if the outstanding commit is complete by the time we are innfs_releage_page, page flags should not have been modified, right?No.
PG_privatemay be cleared while another process is holding the page lock (just likePG_writebackmay).Once cleared,
PG_privatecannot be set again without grabbing the page lock.
Ah, ok. I got stuck there. Thanks for the clarifying.
Signature · 1 line
Suresh Jayaraman
cover Fix for the nfs_release_page() bug
In reply to Trond MyklebustHere are the two proposed patches. The first is needed for both mainline and [email protected]. The second, being a cleanup, will be send to mainline only.
Cheers
Trond
---
Trond Myklebust (2):
NFS: Remove a redundant check for PageFsCache in nfs_migrate_page()
NFS: Fix a bug in nfs_fscache_release_page()
fs/nfs/fscache.c | 9 ++++----- fs/nfs/write.c | 3 +-- 2 files changed, 5 insertions(+), 7 deletions(-)
Signature · 1 line
Signature
A message that is not in the archive (sent off-list or not yet received): 20100208145942.17581.81775.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/[email protected]
PATCH 1/2 NFS: Fix a bug in nfs_fscache_release_page()
Not having an fscache cookie is perfectly valid if the user didn't mount with the fscache option.
This patch fixes http://bugzilla.kernel.org/show_bug.cgi?id=15234
---
fs/nfs/fscache.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-)
fs/nfs/fscache.c +4 -5
@@ -354,12 +354,11 @@ void nfs_fscache_reset_inode_cookie(struct inode *inode)*/ int nfs_fscache_release_page (struct page *page,gfp_t gfp) { -struct nfs_inode *nfsi =NFS_I (page->mapping->host); -struct fscache_cookie *cookie = nfsi->fscache; - -BUG_ON (!cookie); -if (PageFsCache (page)) { +struct nfs_inode *nfsi =NFS_I (page->mapping->host); +struct fscache_cookie *cookie = nfsi->fscache; + +BUG_ON (!cookie);dfprintk (FSCACHE ,"NFS: fscache releasepage (0x%p/0x%p/0x%p)\n" , cookie, page, nfsi);
PATCH 2/2 NFS: Remove a redundant check for PageFsCache in nfs_migrate_page()
In reply to a message not in the archive---
fs/nfs/write.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
fs/nfs/write.c +1 -2
@@ -1598,8 +1598,7 @@ int nfs_migrate_page(struct address_space *mapping, struct page *newpage,struct nfs_page *req;int ret; -if (PageFsCache (page)) -nfs_fscache_release_page (page,GFP_KERNEL ); +nfs_fscache_release_page (page,GFP_KERNEL ); req =nfs_find_and_lock_request (page); ret =PTR_ERR (req);
A message that is not in the archive (sent off-list or not yet received): 20100208145942.17581.83842.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/[email protected]
David Howells
Acked-byQuoted 6 lines · Trond Myklebust
Not having an fscache cookie is perfectly valid if the user didn't mount with the fscache option.
This patch fixes http://bugzilla.kernel.org/show_bug.cgi?id=15234
Signed-off-by Trond Myklebust <[email protected]>
A message that is not in the archive (sent off-list or not yet received): 20100208145942.17581.12206.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/[email protected]
David Howells
Acked-byRe: [PATCH 2/2] NFS: Remove a redundant check for PageFsCache in nfs_migrate_page()
Quoted 1 line · Trond Myklebust
Signed-off-by Trond Myklebust <[email protected]>