Skip to contentSkip to conversation

CIFS: Use invalidate_inode_pages2 instead of invalidate_remote_inode (try #4)

PATCH In review Pavel Shilovsky 3 participants 21 messages Mar 15, 2011 – Mar 23, 2011 19 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 CIFS: Use invalidate_inode_pages2 instead of invalidate_remote_inode (try #4)

Use invalidate_inode_pages2 that don't leave pages even if shrink_page_list() has a temp ref on them. It prevents a data coherency problem when cifs_invalidate_mapping didn't invalidate pages but the client thinks that a data from the cache is uptodate according to an oplock level (exclusive or II).

---
 fs/cifs/inode.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
fs/cifs/inode.c +8 -2
index 41e5651..adb6324 100644
@@ -1691,12 +1691,18 @@ cifs_invalidate_mapping(struct inode *inode)
 
 	cifs_i->invalid_mapping = false;
 
-	/* write back any cached data */
 	if (inode->i_mapping && inode->i_mapping->nrpages != 0) {
+		/* write back any cached data */
 		rc = filemap_write_and_wait(inode->i_mapping);
 		mapping_set_error(inode->i_mapping, rc);
+		rc = invalidate_inode_pages2(inode->i_mapping);
+		if (rc) {
+			cERROR(1, "%s: could not invalidate inode %p", __func__,
+			       inode);
+			cifs_i->invalid_mapping = true;
+		}
 	}
-	invalidate_remote_inode(inode);
+
 	cifs_fscache_reset_inode_cookie(inode);
 }
 
Signature · 1 line
1.7.1

A message that is not in the archive (sent off-list or not yet received): 1300229732-4902-1-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org

#2 lore raw
Quoted 25 lines · On Wed, 16 Mar 2011 01:55:32 +0300 Pavel Shilovsky…

Use invalidate_inode_pages2 that don't leave pages even if shrink_page_list() has a temp ref on them. It prevents a data coherency problem when cifs_invalidate_mapping didn't invalidate pages but the client thinks that a data from the cache is uptodate according to an oplock level (exclusive or II).

---
 fs/cifs/inode.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
fs/cifs/inode.c +3 -1
index 41e5651..adb6324 100644
@@ -1691,12 +1691,18 @@ cifs_invalidate_mapping(struct inode *inode)
 
 	cifs_i->invalid_mapping = false;
 
-	/* write back any cached data */
 	if (inode->i_mapping && inode->i_mapping->nrpages != 0) {
+		/* write back any cached data */
 		rc = filemap_write_and_wait(inode->i_mapping);
 		mapping_set_error(inode->i_mapping, rc);
+		rc = invalidate_inode_pages2(inode->i_mapping);
+		if (rc) {

fs/cifs/inode.c cifs_invalidate_mapping(struct inode *inode) · line 1708

Quoted 10 lines
fs/cifs/inode.c +5 -1
+			cERROR(1, "%s: could not invalidate inode %p", __func__,
+			       inode);
+			cifs_i->invalid_mapping = true;
+		}
 	}
-	invalidate_remote_inode(inode);
+
 	cifs_fscache_reset_inode_cookie(inode);
 }
 

Hi Pavel,

I noticed that Steve has merged this patch, but it doesn't seem like you ever made the change to have EBUSY percolate up to userspace. Are you still planning to fix that?

Signature · 1 line
Jeff Layton <[email protected]>

A message that is not in the archive (sent off-list or not yet received): 20110322074233.546d4553-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org

#4 lore raw

2011/3/22 Jeff Layton <[email protected]>:

Quoted 41 lines
Quoted 25 lines · On Wed, 16 Mar 2011 01:55:32 +0300 Pavel Shilovsky…

Use invalidate_inode_pages2 that don't leave pages even if shrink_page_list() has a temp ref on them. It prevents a data coherency problem when cifs_invalidate_mapping didn't invalidate pages but the client thinks that a data from the cache is uptodate according to an oplock level (exclusive or II).

---
 fs/cifs/inode.c |   10 ++++++++--

 1 files changed, 8 insertions(+), 2 deletions(-)
fs/cifs/inode.c +3 -1
index 41e5651..adb6324 100644
@@ -1691,12 +1691,18 @@ cifs_invalidate_mapping(struct inode *inode)
 
       cifs_i->invalid_mapping = false;
 
-     /* write back any cached data */
       if (inode->i_mapping && inode->i_mapping->nrpages != 0) {
+             /* write back any cached data */
               rc = filemap_write_and_wait(inode->i_mapping);
               mapping_set_error(inode->i_mapping, rc);
+             rc = invalidate_inode_pages2(inode->i_mapping);
+             if (rc) {

fs/cifs/inode.c cifs_invalidate_mapping(struct inode *inode) · line 1708

Quoted 10 lines
fs/cifs/inode.c +5 -1
+                     cERROR(1, "%s: could not invalidate inode %p", __func__,
+                            inode);
+                     cifs_i->invalid_mapping = true;
+             }
       }
-     invalidate_remote_inode(inode);
+
       cifs_fscache_reset_inode_cookie(inode);
  }
 

Hi Pavel,

Quoted 4 lines

I noticed that Steve has merged this patch, but it doesn't seem like you ever made the change to have EBUSY percolate up to userspace. Are you still planning to fix that?

Steve NACK'ed this and we came to agreement to mark a mapping as invalid in this case for now and let the client try invalidate it again when it needs. Of course, it can bring problems with a data coherency if you need to use a cache very strictly.

Signature · 2 lines
Best regards,
Pavel Shilovsky.

A message that is not in the archive (sent off-list or not yet received): AANLkTinGszmNsqFbf5vVstXfEsf5sh+SUZiFexjgBxjY-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#6 lore raw
Quoted 47 lines · On Tue, 22 Mar 2011 15:01:11 +0300 Pavel Shilovsky…

2011/3/22 Jeff Layton <[email protected]>:

Quoted 41 lines
Quoted 25 lines · On Wed, 16 Mar 2011 01:55:32 +0300 Pavel Shilovsky…

Use invalidate_inode_pages2 that don't leave pages even if shrink_page_list() has a temp ref on them. It prevents a data coherency problem when cifs_invalidate_mapping didn't invalidate pages but the client thinks that a data from the cache is uptodate according to an oplock level (exclusive or II).

---
 fs/cifs/inode.c |   10 ++++++++--

 1 files changed, 8 insertions(+), 2 deletions(-)
fs/cifs/inode.c +3 -1
index 41e5651..adb6324 100644
@@ -1691,12 +1691,18 @@ cifs_invalidate_mapping(struct inode *inode)
 
       cifs_i->invalid_mapping = false;
 
-     /* write back any cached data */
       if (inode->i_mapping && inode->i_mapping->nrpages != 0) {
+             /* write back any cached data */
               rc = filemap_write_and_wait(inode->i_mapping);
               mapping_set_error(inode->i_mapping, rc);
+             rc = invalidate_inode_pages2(inode->i_mapping);
+             if (rc) {

fs/cifs/inode.c cifs_invalidate_mapping(struct inode *inode) · line 1708

Quoted 10 lines
fs/cifs/inode.c +5 -1
+                     cERROR(1, "%s: could not invalidate inode %p", __func__,
+                            inode);
+                     cifs_i->invalid_mapping = true;
+             }
       }
-     invalidate_remote_inode(inode);
+
       cifs_fscache_reset_inode_cookie(inode);
  }
 

Hi Pavel,

Quoted 4 lines

I noticed that Steve has merged this patch, but it doesn't seem like you ever made the change to have EBUSY percolate up to userspace. Are you still planning to fix that?

Quoted 5 lines

Steve NACK'ed this and we came to agreement to mark a mapping as invalid in this case for now and let the client try invalidate it again when it needs. Of course, it can bring problems with a data coherency if you need to use a cache very strictly.

Ahh, I must have missed the discussion around that NAK, and I don't see any record of it in the list archives. Steve, can you clarify why you didn't think that approach was acceptible?

Signature · 1 line
Jeff Layton <[email protected]>

A message that is not in the archive (sent off-list or not yet received): 20110322080409.23461155-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org

#8 lore raw
Quoted 56 lines · Jeff Layton
Quoted 47 lines · On Tue, 22 Mar 2011 15:01:11 +0300 Pavel Shilovsky…

2011/3/22 Jeff Layton <[email protected]>:

Quoted 41 lines
Quoted 25 lines · On Wed, 16 Mar 2011 01:55:32 +0300 Pavel Shilovsky…

Use invalidate_inode_pages2 that don't leave pages even if shrink_page_list() has a temp ref on them. It prevents a data coherency problem when cifs_invalidate_mapping didn't invalidate pages but the client thinks that a data from the cache is uptodate according to an oplock level (exclusive or II).

---
 fs/cifs/inode.c |   10 ++++++++--

 1 files changed, 8 insertions(+), 2 deletions(-)
fs/cifs/inode.c +3 -1
index 41e5651..adb6324 100644
@@ -1691,12 +1691,18 @@ cifs_invalidate_mapping(struct inode *inode)
 
       cifs_i->invalid_mapping = false;
 
-     /* write back any cached data */
       if (inode->i_mapping && inode->i_mapping->nrpages != 0) {
+             /* write back any cached data */
               rc = filemap_write_and_wait(inode->i_mapping);
               mapping_set_error(inode->i_mapping, rc);
+             rc = invalidate_inode_pages2(inode->i_mapping);
+             if (rc) {

fs/cifs/inode.c cifs_invalidate_mapping(struct inode *inode) · line 1708

Quoted 10 lines
fs/cifs/inode.c +5 -1
+                     cERROR(1, "%s: could not invalidate inode %p", __func__,
+                            inode);
+                     cifs_i->invalid_mapping = true;
+             }
       }
-     invalidate_remote_inode(inode);
+
       cifs_fscache_reset_inode_cookie(inode);
  }
 

Hi Pavel,

Quoted 4 lines

I noticed that Steve has merged this patch, but it doesn't seem like you ever made the change to have EBUSY percolate up to userspace. Are you still planning to fix that?

Quoted 5 lines

Steve NACK'ed this and we came to agreement to mark a mapping as invalid in this case for now and let the client try invalidate it again when it needs. Of course, it can bring problems with a data coherency if you need to use a cache very strictly.

Quoted 3 lines

Ahh, I must have missed the discussion around that NAK, and I don't see any record of it in the list archives. Steve, can you clarify why you didn't think that approach was acceptible?

Pavel and I discussed the code paths in detail via IRC or chat. I would have to go back and look through the code again, but I thought the issue was that returning
EBUSY (from invalidate_inode_pages2) doesn't make any sense to revalidate_file (e.g. why would a seek return EBUSY even though we successfully updated the correct file size?) who can't use the rc, but by resetting the mapping to invalid_mapping invalidate_inode_pages2 will still get invoked again later (which is all we would do in the caller if we passed it back).

In practice it probably doesn't make much difference for cifs anyway (passing the return code back from invalidate_inode_pages2) because we don't have a "launder_page" operation for cifs and therefore don't return an error, and for the other case it doesn't seem correct to fail a seek because of (page_has_private(page))

Signature · 3 lines
Thanks,

Steve

A message that is not in the archive (sent off-list or not yet received): AANLkTin_dHLJLpZxnmbCM=ukg7_xBi7YHg_YRaaYUmkj-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#10 lore raw
Quoted 71 lines · On Tue, 22 Mar 2011 09:50:43 -0500 Steve French…
Quoted 56 lines · Jeff Layton
Quoted 47 lines · On Tue, 22 Mar 2011 15:01:11 +0300 Pavel Shilovsky…

2011/3/22 Jeff Layton <[email protected]>:

Quoted 41 lines
Quoted 25 lines · On Wed, 16 Mar 2011 01:55:32 +0300 Pavel Shilovsky…

Use invalidate_inode_pages2 that don't leave pages even if shrink_page_list() has a temp ref on them. It prevents a data coherency problem when cifs_invalidate_mapping didn't invalidate pages but the client thinks that a data from the cache is uptodate according to an oplock level (exclusive or II).

---
 fs/cifs/inode.c |   10 ++++++++--

 1 files changed, 8 insertions(+), 2 deletions(-)
fs/cifs/inode.c +3 -1
index 41e5651..adb6324 100644
@@ -1691,12 +1691,18 @@ cifs_invalidate_mapping(struct inode *inode)
 
       cifs_i->invalid_mapping = false;
 
-     /* write back any cached data */
       if (inode->i_mapping && inode->i_mapping->nrpages != 0) {
+             /* write back any cached data */
               rc = filemap_write_and_wait(inode->i_mapping);
               mapping_set_error(inode->i_mapping, rc);
+             rc = invalidate_inode_pages2(inode->i_mapping);
+             if (rc) {

fs/cifs/inode.c cifs_invalidate_mapping(struct inode *inode) · line 1708

Quoted 10 lines
fs/cifs/inode.c +5 -1
+                     cERROR(1, "%s: could not invalidate inode %p", __func__,
+                            inode);
+                     cifs_i->invalid_mapping = true;
+             }
       }
-     invalidate_remote_inode(inode);
+
       cifs_fscache_reset_inode_cookie(inode);
  }
 

Hi Pavel,

Quoted 4 lines

I noticed that Steve has merged this patch, but it doesn't seem like you ever made the change to have EBUSY percolate up to userspace. Are you still planning to fix that?

Quoted 5 lines

Steve NACK'ed this and we came to agreement to mark a mapping as invalid in this case for now and let the client try invalidate it again when it needs. Of course, it can bring problems with a data coherency if you need to use a cache very strictly.

Quoted 3 lines

Ahh, I must have missed the discussion around that NAK, and I don't see any record of it in the list archives. Steve, can you clarify why you didn't think that approach was acceptible?

Pavel and I discussed the code paths in detail via IRC or chat. I would have to go back and look through the code again, but I thought the issue was that returning
EBUSY (from invalidate_inode_pages2) doesn't make any sense to revalidate_file (e.g. why would a seek return EBUSY even though we successfully updated the correct file size?) who can't use the rc, but by resetting the mapping to invalid_mapping invalidate_inode_pages2 will still get invoked again later (which is all we would do in the caller if we passed it back).

Quoted 6 lines

In practice it probably doesn't make much difference for cifs anyway (passing the return code back from invalidate_inode_pages2) because we don't have a "launder_page" operation for cifs and therefore don't return an error, and for the other case it doesn't seem correct to fail a seek because of (page_has_private(page))

It does however make sense to return an error if you're going to invalidate a page and can't because the page is dirty:

                        ret2 = do_launder_page(mapping, page);
                        if (ret2 == 0) {
                                if (!invalidate_complete_page2(mapping, page))
                                        ret2 = -EBUSY;
                        }

do_launder_page returns 0 if there is no launder_page op...

invalidate_complete_page does this:

        if (PageDirty(page))
                goto failed;

...so the fact that we don't have a launder_page operation doesn't mean that we'll never return an error here.

It makes no sense at all to do a cERROR printk for this. It'll make users go "huh?", and won't help us to debug anything.

Signature · 1 line
Jeff Layton <[email protected]>

A message that is not in the archive (sent off-list or not yet received): 20110322111711.55365655-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org

#12 lore raw
Quoted 94 lines · Jeff Layton
Quoted 71 lines · On Tue, 22 Mar 2011 09:50:43 -0500 Steve French…
Quoted 56 lines · Jeff Layton
Quoted 47 lines · On Tue, 22 Mar 2011 15:01:11 +0300 Pavel Shilovsky…

2011/3/22 Jeff Layton <[email protected]>:

Quoted 41 lines
Quoted 25 lines · On Wed, 16 Mar 2011 01:55:32 +0300 Pavel Shilovsky…

Use invalidate_inode_pages2 that don't leave pages even if shrink_page_list() has a temp ref on them. It prevents a data coherency problem when cifs_invalidate_mapping didn't invalidate pages but the client thinks that a data from the cache is uptodate according to an oplock level (exclusive or II).

---
 fs/cifs/inode.c |   10 ++++++++--

 1 files changed, 8 insertions(+), 2 deletions(-)
fs/cifs/inode.c +3 -1
index 41e5651..adb6324 100644
@@ -1691,12 +1691,18 @@ cifs_invalidate_mapping(struct inode *inode)
 
       cifs_i->invalid_mapping = false;
 
-     /* write back any cached data */
       if (inode->i_mapping && inode->i_mapping->nrpages != 0) {
+             /* write back any cached data */
               rc = filemap_write_and_wait(inode->i_mapping);
               mapping_set_error(inode->i_mapping, rc);
+             rc = invalidate_inode_pages2(inode->i_mapping);
+             if (rc) {

fs/cifs/inode.c cifs_invalidate_mapping(struct inode *inode) · line 1708

Quoted 10 lines
fs/cifs/inode.c +5 -1
+                     cERROR(1, "%s: could not invalidate inode %p", __func__,
+                            inode);
+                     cifs_i->invalid_mapping = true;
+             }
       }
-     invalidate_remote_inode(inode);
+
       cifs_fscache_reset_inode_cookie(inode);
  }
 

Hi Pavel,

Quoted 4 lines

I noticed that Steve has merged this patch, but it doesn't seem like you ever made the change to have EBUSY percolate up to userspace. Are you still planning to fix that?

Quoted 5 lines

Steve NACK'ed this and we came to agreement to mark a mapping as invalid in this case for now and let the client try invalidate it again when it needs. Of course, it can bring problems with a data coherency if you need to use a cache very strictly.

Quoted 3 lines

Ahh, I must have missed the discussion around that NAK, and I don't see any record of it in the list archives. Steve, can you clarify why you didn't think that approach was acceptible?

Pavel and I discussed the code paths in detail via IRC or chat.  I would have to go back and look through the code again, but I thought the issue was that returning
EBUSY (from invalidate_inode_pages2) doesn't make any sense to revalidate_file (e.g. why would a seek return EBUSY even though we successfully updated the correct file size?) who can't use the rc, but by resetting the mapping to invalid_mapping invalidate_inode_pages2 will still get invoked again later (which is all we would do in the caller if we passed it back).

Quoted 6 lines

In practice it probably doesn't make much difference for cifs anyway (passing the return code back from invalidate_inode_pages2) because we don't have a "launder_page" operation for cifs and therefore don't return an error, and for the other case it doesn't seem correct to fail a seek because of (page_has_private(page))

It does however make sense to return an error if you're going to invalidate a page and can't because the page is dirty:

                       ret2 = do_launder_page(mapping, page);
                       if (ret2 == 0) {
                               if (!invalidate_complete_page2(mapping, page)) ret2 = -EBUSY;
                       }

do_launder_page returns 0 if there is no launder_page op...

invalidate_complete_page does this:

Quoted 8 lines

       if (PageDirty(page))
               goto failed;

...so the fact that we don't have a launder_page operation doesn't mean that we'll never return an error here.

It makes no sense at all to do a cERROR printk for this. It'll make users go "huh?", and won't help us to debug anything.

but how could we have PageDirty? We just did filemap_write_and_wait (unless some private mmap case where it may be ok?).

Signature · 3 lines
Thanks,

Steve

A message that is not in the archive (sent off-list or not yet received): AANLkTikMbyg6FK7tgcb-a9kc_2r-rToA2x0AvY_KHQUw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#14 lore raw
Quoted 98 lines · On Tue, 22 Mar 2011 11:24:02 -0500 Steve French…
Quoted 97 lines · Jeff Layton
Quoted 71 lines · On Tue, 22 Mar 2011 09:50:43 -0500 Steve French…
Quoted 56 lines · Jeff Layton
Quoted 47 lines · On Tue, 22 Mar 2011 15:01:11 +0300 Pavel Shilovsky…

2011/3/22 Jeff Layton <[email protected]>:

Quoted 41 lines
Quoted 25 lines · On Wed, 16 Mar 2011 01:55:32 +0300 Pavel Shilovsky…

Use invalidate_inode_pages2 that don't leave pages even if shrink_page_list() has a temp ref on them. It prevents a data coherency problem when cifs_invalidate_mapping didn't invalidate pages but the client thinks that a data from the cache is uptodate according to an oplock level (exclusive or II).

---
 fs/cifs/inode.c |   10 ++++++++--

 1 files changed, 8 insertions(+), 2 deletions(-)
fs/cifs/inode.c +3 -1
index 41e5651..adb6324 100644
@@ -1691,12 +1691,18 @@ cifs_invalidate_mapping(struct inode *inode)
 
       cifs_i->invalid_mapping = false;
 
-     /* write back any cached data */
       if (inode->i_mapping && inode->i_mapping->nrpages != 0) {
+             /* write back any cached data */
               rc = filemap_write_and_wait(inode->i_mapping);
               mapping_set_error(inode->i_mapping, rc);
+             rc = invalidate_inode_pages2(inode->i_mapping);
+             if (rc) {

fs/cifs/inode.c cifs_invalidate_mapping(struct inode *inode) · line 1708

Quoted 10 lines
fs/cifs/inode.c +5 -1
+                     cERROR(1, "%s: could not invalidate inode %p", __func__,
+                            inode);
+                     cifs_i->invalid_mapping = true;
+             }
       }
-     invalidate_remote_inode(inode);
+
       cifs_fscache_reset_inode_cookie(inode);
  }
 

Hi Pavel,

Quoted 4 lines

I noticed that Steve has merged this patch, but it doesn't seem like you ever made the change to have EBUSY percolate up to userspace. Are you still planning to fix that?

Quoted 5 lines

Steve NACK'ed this and we came to agreement to mark a mapping as invalid in this case for now and let the client try invalidate it again when it needs. Of course, it can bring problems with a data coherency if you need to use a cache very strictly.

Quoted 3 lines

Ahh, I must have missed the discussion around that NAK, and I don't see any record of it in the list archives. Steve, can you clarify why you didn't think that approach was acceptible?

Pavel and I discussed the code paths in detail via IRC or chat.  I would have to go back and look through the code again, but I thought the issue was that returning
EBUSY (from invalidate_inode_pages2) doesn't make any sense to revalidate_file (e.g. why would a seek return EBUSY even though we successfully updated the correct file size?) who can't use the rc, but by resetting the mapping to invalid_mapping invalidate_inode_pages2 will still get invoked again later (which is all we would do in the caller if we passed it back).

Quoted 6 lines

In practice it probably doesn't make much difference for cifs anyway (passing the return code back from invalidate_inode_pages2) because we don't have a "launder_page" operation for cifs and therefore don't return an error, and for the other case it doesn't seem correct to fail a seek because of (page_has_private(page))

It does however make sense to return an error if you're going to invalidate a page and can't because the page is dirty:

                       ret2 = do_launder_page(mapping, page);
                       if (ret2 == 0) {
                               if (!invalidate_complete_page2(mapping, page)) ret2 = -EBUSY;
                       }

do_launder_page returns 0 if there is no launder_page op...

invalidate_complete_page does this:

       if (PageDirty(page))
               goto failed;

Quoted 9 lines
Quoted 5 lines

...so the fact that we don't have a launder_page operation doesn't mean that we'll never return an error here.

It makes no sense at all to do a cERROR printk for this. It'll make users go "huh?", and won't help us to debug anything.

but how could we have PageDirty? We just did filemap_write_and_wait (unless some private mmap case where it may be ok?).

Nothing prevents the page from being redirtied after writeback.

Signature · 1 line
Jeff Layton <[email protected]>

A message that is not in the archive (sent off-list or not yet received): 20110322123549.022e590e-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org

#16 lore raw

Isn't there a lock across lseek?

Quoted 116 lines · Jeff Layton
Quoted 98 lines · On Tue, 22 Mar 2011 11:24:02 -0500 Steve French…
Quoted 97 lines · Jeff Layton
Quoted 71 lines · On Tue, 22 Mar 2011 09:50:43 -0500 Steve French…
Quoted 56 lines · Jeff Layton
Quoted 47 lines · On Tue, 22 Mar 2011 15:01:11 +0300 Pavel Shilovsky…

2011/3/22 Jeff Layton <[email protected]>:

Quoted 41 lines
Quoted 25 lines · On Wed, 16 Mar 2011 01:55:32 +0300 Pavel Shilovsky…

Use invalidate_inode_pages2 that don't leave pages even if shrink_page_list() has a temp ref on them. It prevents a data coherency problem when cifs_invalidate_mapping didn't invalidate pages but the client thinks that a data from the cache is uptodate according to an oplock level (exclusive or II).

---
 fs/cifs/inode.c |   10 ++++++++--

 1 files changed, 8 insertions(+), 2 deletions(-)
fs/cifs/inode.c +3 -1
index 41e5651..adb6324 100644
@@ -1691,12 +1691,18 @@ cifs_invalidate_mapping(struct inode *inode)
 
       cifs_i->invalid_mapping = false;
 
-     /* write back any cached data */
       if (inode->i_mapping && inode->i_mapping->nrpages != 0) {
+             /* write back any cached data */
               rc = filemap_write_and_wait(inode->i_mapping);
               mapping_set_error(inode->i_mapping, rc);
+             rc = invalidate_inode_pages2(inode->i_mapping);
+             if (rc) {

fs/cifs/inode.c cifs_invalidate_mapping(struct inode *inode) · line 1708

Quoted 10 lines
fs/cifs/inode.c +5 -1
+                     cERROR(1, "%s: could not invalidate inode %p", __func__,
+                            inode);
+                     cifs_i->invalid_mapping = true;
+             }
       }
-     invalidate_remote_inode(inode);
+
       cifs_fscache_reset_inode_cookie(inode);
  }
 

Hi Pavel,

Quoted 4 lines

I noticed that Steve has merged this patch, but it doesn't seem like you ever made the change to have EBUSY percolate up to userspace. Are you still planning to fix that?

Quoted 5 lines

Steve NACK'ed this and we came to agreement to mark a mapping as invalid in this case for now and let the client try invalidate it again when it needs. Of course, it can bring problems with a data coherency if you need to use a cache very strictly.

Quoted 3 lines

Ahh, I must have missed the discussion around that NAK, and I don't see any record of it in the list archives. Steve, can you clarify why you didn't think that approach was acceptible?

Pavel and I discussed the code paths in detail via IRC or chat.  I would have to go back and look through the code again, but I thought the issue was that returning
EBUSY (from invalidate_inode_pages2) doesn't make any sense to revalidate_file (e.g. why would a seek return EBUSY even though we successfully updated the correct file size?) who can't use the rc, but by resetting the mapping to invalid_mapping invalidate_inode_pages2 will still get invoked again later (which is all we would do in the caller if we passed it back).

Quoted 6 lines

In practice it probably doesn't make much difference for cifs anyway (passing the return code back from invalidate_inode_pages2) because we don't have a "launder_page" operation for cifs and therefore don't return an error, and for the other case it doesn't seem correct to fail a seek because of (page_has_private(page))

It does however make sense to return an error if you're going to invalidate a page and can't because the page is dirty:

                       ret2 = do_launder_page(mapping, page);
                       if (ret2 == 0) {
                               if (!invalidate_complete_page2(mapping, page)) ret2 = -EBUSY;
                       }

do_launder_page returns 0 if there is no launder_page op...

invalidate_complete_page does this:

       if (PageDirty(page))
               goto failed;

Quoted 9 lines
Quoted 5 lines

...so the fact that we don't have a launder_page operation doesn't mean that we'll never return an error here.

It makes no sense at all to do a cERROR printk for this. It'll make users go "huh?", and won't help us to debug anything.

but how could we have PageDirty?  We just did filemap_write_and_wait (unless some private mmap case where it may be ok?).

Nothing prevents the page from being redirtied after writeback.

--
Jeff Layton <[email protected]>

Signature · 3 lines
Thanks,

Steve

A message that is not in the archive (sent off-list or not yet received): AANLkTim=J7Y-b07HHKypfxgXL=jpgVVaZ1hn2201Amny-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#18 lore raw
Quoted 7 lines · Steve French

Isn't there a lock across lseek?

Quoted 5 lines
Quoted 3 lines

but how could we have PageDirty?  We just did filemap_write_and_wait (unless some private mmap case where it may be ok?).

Nothing prevents the page from being redirtied after writeback.

If it is redirtied, we immediately do a filemap_fdatawrite anyway (in the write/aio_write path) so there isn't a delay in writing data to the server.

Signature · 3 lines
Thanks,

Steve

A message that is not in the archive (sent off-list or not yet received): AANLkTikg4WQrguR_cvvkxXZ8XomO=3ySjPzT67yO_cvk-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#20 lore raw
Quoted 7 lines · On Tue, 22 Mar 2011 11:46:54 -0500 Steve French…
Quoted 6 lines · Steve French

Isn't there a lock across lseek?

Quoted 4 lines
Quoted 3 lines

but how could we have PageDirty?  We just did filemap_write_and_wait (unless some private mmap case where it may be ok?).

Quoted 6 lines
Quoted 1 line
Quoted 1 line

Nothing prevents the page from being redirtied after writeback.

If it is redirtied, we immediately do a filemap_fdatawrite anyway (in the write/aio_write path) so there isn't a delay in writing data to the server.

The bottom line is that you're asking to revalidate the file, finding that it has changed and are trying to invalidate the pagecache. Some of those pages are may not be invalidated though, so you won't end up with new data from the server if you go to do a read.

The whole point of this patch is to fix data-integrity issues, right? So why only do a half-assed job of that?

Signature · 1 line
Jeff Layton <[email protected]>

A message that is not in the archive (sent off-list or not yet received): 20110322130334.0680b9a3-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org

#22 lore raw
Quoted 17 lines · Jeff Layton
Quoted 7 lines · On Tue, 22 Mar 2011 11:46:54 -0500 Steve French…
Quoted 6 lines · Steve French

Isn't there a lock across lseek?

Quoted 4 lines
Quoted 3 lines

but how could we have PageDirty?  We just did filemap_write_and_wait (unless some private mmap case where it may be ok?).

Quoted 6 lines
Quoted 1 line
Quoted 1 line

Nothing prevents the page from being redirtied after writeback.

If it is redirtied, we immediately do a filemap_fdatawrite anyway (in the write/aio_write path) so there isn't a delay in writing data to the server.

Quoted 7 lines

The bottom line is that you're asking to revalidate the file, finding that it has changed and are trying to invalidate the pagecache. Some of those pages are may not be invalidated though, so you won't end up with new data from the server if you go to do a read.

The whole point of this patch is to fix data-integrity issues, right? So why only do a half-assed job of that?

The data gets written (immediately). The page gets freed either immediately or (in the unlikely event it was busy) the next time we do a seek or revalidate or any of the other places that checks the invalidate flag. Not sure how there is a data integrity issue. If we do return EBUSY - it makes no sense on seek (we got the updated file size) - the only case it might make sense on is strictcache read which was racing with an mmapped write and in that case the data the client has is up to date and the next read will toss the page out of cache
since the mapping is marked invalid. Seems a lot of complexity to
return EBUSY to strictcache read since there isn't anything it can do about it other than spin and retry and we would retry anyway on the next operation on that file.

Signature · 3 lines
Thanks,

Steve

A message that is not in the archive (sent off-list or not yet received): AANLkTikSUaLsEk5CNfVMXqLN4z=UGOeyYoMkTGQBLf2A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#24 lore raw
Quoted 26 lines · On Tue, 22 Mar 2011 12:13:03 -0500 Steve French…
Quoted 17 lines · Jeff Layton
Quoted 7 lines · On Tue, 22 Mar 2011 11:46:54 -0500 Steve French…
Quoted 6 lines · Steve French

Isn't there a lock across lseek?

Quoted 4 lines
Quoted 3 lines

but how could we have PageDirty?  We just did filemap_write_and_wait (unless some private mmap case where it may be ok?).

Quoted 6 lines
Quoted 1 line
Quoted 1 line

Nothing prevents the page from being redirtied after writeback.

If it is redirtied, we immediately do a filemap_fdatawrite anyway (in the write/aio_write path) so there isn't a delay in writing data to the server.

Quoted 7 lines

The bottom line is that you're asking to revalidate the file, finding that it has changed and are trying to invalidate the pagecache. Some of those pages are may not be invalidated though, so you won't end up with new data from the server if you go to do a read.

The whole point of this patch is to fix data-integrity issues, right? So why only do a half-assed job of that?

Quoted 13 lines

The data gets written (immediately). The page gets freed either immediately or (in the unlikely event it was busy) the next time we do a seek or revalidate or any of the other places that checks the invalidate flag. Not sure how there is a data integrity issue. If we do return EBUSY - it makes no sense on seek (we got the updated file size) - the only case it might make sense on is strictcache read which was racing with an mmapped write and in that case the data the client has is up to date and the next read will toss the page out of cache
since the mapping is marked invalid. Seems a lot of complexity to
return EBUSY to strictcache read since there isn't anything it can do about it other than spin and retry and we would retry anyway on the next operation on that file.

The fact that data gets written immediately is immaterial. It's still in cache so a pagefault can find it, and it's still potentially wrong. I'm also not clear on why you're focused on seeks.

What matters is that a page got dirtied while it had data on it that we were getting ready to toss out. The right course of action at that point is to try and write out the data and then return an error if that doesn't "fix" it.

Signature · 1 line
Jeff Layton <[email protected]>

A message that is not in the archive (sent off-list or not yet received): 20110322134246.4b9e497e-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org

#26 lore raw
Quoted 43 lines · Jeff Layton
Quoted 26 lines · On Tue, 22 Mar 2011 12:13:03 -0500 Steve French…
Quoted 17 lines · Jeff Layton
Quoted 7 lines · On Tue, 22 Mar 2011 11:46:54 -0500 Steve French…
Quoted 6 lines · Steve French

Isn't there a lock across lseek?

Quoted 4 lines
Quoted 3 lines

but how could we have PageDirty?  We just did filemap_write_and_wait (unless some private mmap case where it may be ok?).

Quoted 6 lines
Quoted 1 line
Quoted 1 line

Nothing prevents the page from being redirtied after writeback.

If it is redirtied, we immediately do a filemap_fdatawrite anyway (in the write/aio_write path) so there isn't a delay in writing data to the server.

Quoted 7 lines

The bottom line is that you're asking to revalidate the file, finding that it has changed and are trying to invalidate the pagecache. Some of those pages are may not be invalidated though, so you won't end up with new data from the server if you go to do a read.

The whole point of this patch is to fix data-integrity issues, right? So why only do a half-assed job of that?

Quoted 13 lines

The data gets written (immediately).  The page gets freed either immediately or (in the unlikely event it was busy) the next time we do a seek or revalidate or any of the other places that checks the invalidate flag.  Not sure how there is a data integrity issue.  If we do return EBUSY - it makes no sense on seek (we got the updated file size) - the only case it might make sense on is strictcache read which was racing with an mmapped write and in that case the data the client has is up to date and the next read will toss the page out of cache since the mapping is marked invalid.   Seems a lot of complexity to return EBUSY to strictcache read since there isn't anything it can do about it other than spin and retry and we would retry anyway on the next operation on that file.

Quoted 7 lines

The fact that data gets written immediately is immaterial. It's still in cache so a pagefault can find it, and it's still potentially wrong. I'm also not clear on why you're focused on seeks.

What matters is that a page got dirtied while it had data on it that we were getting ready to toss out. The right course of action at that point is to try and write out the data and then return an error

Other than for strict_fsync (which looks like it should be able to return an error and doesn't) - return an error to who? We save errors on filemap_fdatawrite in the mapping. Of the other callers of
invalidate_mapping: the most common ones: revalidate doesn't care that write and read are racing with each other, and lseek doesn't care, and there is no data integrity issue. All the data is written immediately, the page is tossed from the cache as soon as it is not in the middle of a write (presumably the next operation on it). Read is getting the most current copy of the page out of the client's page cache (since it is in the middle of a local write, the client's copy is more current anyway).

If there were an error on filemap_fdatawrite it is saved in the mapping (doesn't that returned it on the next write or flush). It does look like we should return an error back on strict_fsync though if filemap_fdatawrite failed.

If tossing the page out of the page cache is delayed until the next read, write or seek that seems ok to me - but we should make sure that fsync (and deferred errors returned on write) does return errors - and there may be a hole in the case of strict fsync

Signature · 3 lines
Thanks,

Steve

A message that is not in the archive (sent off-list or not yet received): AANLkTi=zcYODYnx1q1bzBQtt2z7w1rkRxSTNTrK4u=7d-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#28 lore raw

Pavel,
Jeff and I talked about invalidate_mapping and its uses this afternoon. A few comments:
1) Take a look at what happens on filemap_fdatawait call in
invalidate_mapping to see if it makes sense to return errors through back to some of the callers of invalidate_mapping, in particular, strict_fsync. If we can't write out the file data (ENOSPC, or host down etc.), we want to make sure that the return code gets sent back on any calls that can reasonably expect such an error.
2) If invalidate_inode_pages2 fails (e.g. with EBUSY, because one of the pages couldn't be freed from the mapping because it just got redirtied right after we flushed it the line before) we set the mapping to invalid but don't check

    cifs_i->invalid_mapping

in many places. Should we add checks for cifs_i->invalid_mapping in more places?
3) The error message below in invalidate_mapping (on EBUSY) should
be removed or changed to an cFYI:

           cERROR(1, "%s: could not invalidate inode %p", __func__, inode);
Signature · 3 lines
Thanks,

Steve

A message that is not in the archive (sent off-list or not yet received): AANLkTimBdrWfAXZ4Ea_K33PyFN_REfNwcH7JjW71mJnh-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#30 lore raw

2011/3/23 Steve French <[email protected]>:

Quoted 9 lines

Pavel,
Jeff and I talked about invalidate_mapping and its uses this afternoon.  A few comments:
1)   Take a look at what happens on filemap_fdatawait call in invalidate_mapping to see if it makes sense to return errors through back to some of the callers of invalidate_mapping, in particular, strict_fsync.  If we can't write out the file data (ENOSPC, or host down etc.), we want to make sure that the return code gets sent back on any calls that can reasonably expect such an error.

vfs_fsync_range has already done filemap_fdatawait call - so, in this case there is no need to do it again in cifs_invalidate_mapping. The only reason for calling this is to invalidate_inode_pages2 but any error there shouldn't affect fsync behavior, as I think.

Quoted 7 lines

2) If invalidate_inode_pages2 fails (e.g. with EBUSY, because one of the pages couldn't be freed from the mapping because it just got redirtied right after we flushed it the line before) we set the mapping to invalid but don't check cifs_i->invalid_mapping
in many places.  Should we add checks for cifs_i->invalid_mapping in more places?

The one place where we should add such a check is read call, but it needs cifs_revalidate_file instead (that I am going to provide next) before generic_file_aio_read. In this case cifs_revalidate will check for invalid_mapping and needs to return a error if we could not invalidate all inode pages in cifs_invalidate_mapping (because it returns wrong data to the read call). But as you noticed lseek shouldn't think about this error and it uses cifs_revalidate_file too.

So, we may add extra check for -EBUSY error code in callers of cifs_revalidate_{dentry,file} and cifs_invaliadate_mapping and separate them into two groups:
1) that aware about -EBUSY error code and return a error the it's caller. these are: cifs_d_revalidate, cifs_file_aio_read (future implementation), cifs_file_strict_mmap.
2) that doesn't aware about it and return ok in this case. these are: cifs_getattrs, cifs_lseek, cifs_fsync.

Thoughts?

Signature · 2 lines
Best regards,
Pavel Shilovsky.

A message that is not in the archive (sent off-list or not yet received): AANLkTikPTVfiz4FNwu-i=1pHjE92vQgUh+eJLHY6j9nW-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#32 lore raw
Quoted 41 lines · On Wed, 23 Mar 2011 12:27:31 +0300 Pavel Shilovsky…

2011/3/23 Steve French <[email protected]>:

Quoted 9 lines

Pavel,
Jeff and I talked about invalidate_mapping and its uses this afternoon.  A few comments:
1)   Take a look at what happens on filemap_fdatawait call in invalidate_mapping to see if it makes sense to return errors through back to some of the callers of invalidate_mapping, in particular, strict_fsync.  If we can't write out the file data (ENOSPC, or host down etc.), we want to make sure that the return code gets sent back on any calls that can reasonably expect such an error.

vfs_fsync_range has already done filemap_fdatawait call - so, in this case there is no need to do it again in cifs_invalidate_mapping. The only reason for calling this is to invalidate_inode_pages2 but any error there shouldn't affect fsync behavior, as I think.

Quoted 7 lines

2) If invalidate_inode_pages2 fails (e.g. with EBUSY, because one of the pages couldn't be freed from the mapping because it just got redirtied right after we flushed it the line before) we set the mapping to invalid but don't check cifs_i->invalid_mapping
in many places.  Should we add checks for cifs_i->invalid_mapping in more places?

The one place where we should add such a check is read call, but it needs cifs_revalidate_file instead (that I am going to provide next) before generic_file_aio_read. In this case cifs_revalidate will check for invalid_mapping and needs to return a error if we could not invalidate all inode pages in cifs_invalidate_mapping (because it returns wrong data to the read call). But as you noticed lseek shouldn't think about this error and it uses cifs_revalidate_file too.

So, we may add extra check for -EBUSY error code in callers of cifs_revalidate_{dentry,file} and cifs_invaliadate_mapping and separate them into two groups:
1) that aware about -EBUSY error code and return a error the it's caller. these are: cifs_d_revalidate, cifs_file_aio_read (future implementation), cifs_file_strict_mmap.
2) that doesn't aware about it and return ok in this case. these are: cifs_getattrs, cifs_lseek, cifs_fsync.

Quoted 2 lines

Thoughts?

The main reason I think we need to reconsider that error is that I spent several months tracking down a rather nasty data corruption bug relating to mmap on NFS in RHEL5 a few years ago:

    https://bugzilla.redhat.com/show_bug.cgi?id=435291

Part of the problem there was that the NFS client ignored the return code from invalidate_inode_pages2. The other part of the problem was a lack of synchronization between mmap calls and the page fault handler.

Needless to say, this was not a fun problem to track down. I think you need to be very careful about ignoring errors from invalidate_inode_pages2 and think carefully about what a failure there means for all cases.

Signature · 1 line
Jeff Layton <[email protected]>

A message that is not in the archive (sent off-list or not yet received): 20110323121428.398f4d4c-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org

#34 lore raw
Quoted 53 lines · Jeff Layton
Quoted 41 lines · On Wed, 23 Mar 2011 12:27:31 +0300 Pavel Shilovsky…

2011/3/23 Steve French <[email protected]>:

Quoted 9 lines

Pavel,
Jeff and I talked about invalidate_mapping and its uses this afternoon.  A few comments:
1)   Take a look at what happens on filemap_fdatawait call in invalidate_mapping to see if it makes sense to return errors through back to some of the callers of invalidate_mapping, in particular, strict_fsync.  If we can't write out the file data (ENOSPC, or host down etc.), we want to make sure that the return code gets sent back on any calls that can reasonably expect such an error.

vfs_fsync_range has already done filemap_fdatawait call - so, in this case there is no need to do it again in cifs_invalidate_mapping. The only reason for calling this is to invalidate_inode_pages2 but any error there shouldn't affect fsync behavior, as I think.

Quoted 7 lines

2) If invalidate_inode_pages2 fails (e.g. with EBUSY, because one of the pages couldn't be freed from the mapping because it just got redirtied right after we flushed it the line before) we set the mapping to invalid but don't check cifs_i->invalid_mapping
in many places.  Should we add checks for cifs_i->invalid_mapping in more places?

The one place where we should add such a check is read call, but it needs cifs_revalidate_file instead (that I am going to provide next) before generic_file_aio_read. In this case cifs_revalidate will check for invalid_mapping and needs to return a error if we could not invalidate all inode pages in cifs_invalidate_mapping (because it returns wrong data to the read call). But as you noticed lseek shouldn't think about this error and it uses cifs_revalidate_file too.

So, we may add extra check for -EBUSY error code in callers of cifs_revalidate_{dentry,file} and cifs_invaliadate_mapping and separate them into two groups:
1) that aware about -EBUSY error code and return a error the it's caller. these are: cifs_d_revalidate, cifs_file_aio_read (future implementation), cifs_file_strict_mmap.
2) that doesn't aware about it and return ok in this case. these are: cifs_getattrs, cifs_lseek, cifs_fsync.

Quoted 2 lines

Thoughts?

The main reason I think we need to reconsider that error is that I spent several months tracking down a rather nasty data corruption bug relating to mmap on NFS in RHEL5 a few years ago:

   https://bugzilla.redhat.com/show_bug.cgi?id=435291

Quoted 8 lines

Part of the problem there was that the NFS client ignored the return code from invalidate_inode_pages2. The other part of the problem was a lack of synchronization between mmap calls and the page fault handler.

Needless to say, this was not a fun problem to track down. I think you need to be very careful about ignoring errors from invalidate_inode_pages2 and think carefully about what a failure there means for all cases.

I agree - need to be careful, but IIRC the NFS problem would be that it has a launder_page method which is returning an error through invalidate_inode_pages2 while in the cifs case the data is forced to be written out through filemap_fdatawrite or filemap_write_and_wait.

Signature · 3 lines
Thanks,

Steve

A message that is not in the archive (sent off-list or not yet received): AANLkTimtOTGO6YPFwuRJGcZrxRk9VwjtA4kWOB_4RKDd-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#36 lore raw
Quoted 63 lines · On Wed, 23 Mar 2011 12:32:03 -0500 Steve French…
Quoted 53 lines · Jeff Layton
Quoted 41 lines · On Wed, 23 Mar 2011 12:27:31 +0300 Pavel Shilovsky…

2011/3/23 Steve French <[email protected]>:

Quoted 9 lines

Pavel,
Jeff and I talked about invalidate_mapping and its uses this afternoon.  A few comments:
1)   Take a look at what happens on filemap_fdatawait call in invalidate_mapping to see if it makes sense to return errors through back to some of the callers of invalidate_mapping, in particular, strict_fsync.  If we can't write out the file data (ENOSPC, or host down etc.), we want to make sure that the return code gets sent back on any calls that can reasonably expect such an error.

vfs_fsync_range has already done filemap_fdatawait call - so, in this case there is no need to do it again in cifs_invalidate_mapping. The only reason for calling this is to invalidate_inode_pages2 but any error there shouldn't affect fsync behavior, as I think.

Quoted 7 lines

2) If invalidate_inode_pages2 fails (e.g. with EBUSY, because one of the pages couldn't be freed from the mapping because it just got redirtied right after we flushed it the line before) we set the mapping to invalid but don't check cifs_i->invalid_mapping
in many places.  Should we add checks for cifs_i->invalid_mapping in more places?

The one place where we should add such a check is read call, but it needs cifs_revalidate_file instead (that I am going to provide next) before generic_file_aio_read. In this case cifs_revalidate will check for invalid_mapping and needs to return a error if we could not invalidate all inode pages in cifs_invalidate_mapping (because it returns wrong data to the read call). But as you noticed lseek shouldn't think about this error and it uses cifs_revalidate_file too.

So, we may add extra check for -EBUSY error code in callers of cifs_revalidate_{dentry,file} and cifs_invaliadate_mapping and separate them into two groups:
1) that aware about -EBUSY error code and return a error the it's caller. these are: cifs_d_revalidate, cifs_file_aio_read (future implementation), cifs_file_strict_mmap.
2) that doesn't aware about it and return ok in this case. these are: cifs_getattrs, cifs_lseek, cifs_fsync.

Quoted 2 lines

Thoughts?

The main reason I think we need to reconsider that error is that I spent several months tracking down a rather nasty data corruption bug relating to mmap on NFS in RHEL5 a few years ago:

   https://bugzilla.redhat.com/show_bug.cgi?id=435291

Quoted 8 lines

Part of the problem there was that the NFS client ignored the return code from invalidate_inode_pages2. The other part of the problem was a lack of synchronization between mmap calls and the page fault handler.

Needless to say, this was not a fun problem to track down. I think you need to be very careful about ignoring errors from invalidate_inode_pages2 and think carefully about what a failure there means for all cases.

Quoted 5 lines

I agree - need to be careful, but IIRC the NFS problem would be that it has a launder_page method which is returning an error through invalidate_inode_pages2 while in the cifs case the data is forced to be written out through filemap_fdatawrite or filemap_write_and_wait.

No. RHEL5 at that time didn't have a launder page method (it does now, but that's another story).

Signature · 1 line
Jeff Layton <[email protected]>

A message that is not in the archive (sent off-list or not yet received): 20110323135626.1fe56d84-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org

#38 lore raw

2011/3/23 Jeff Layton <[email protected]>:

Quoted 72 lines
Quoted 63 lines · On Wed, 23 Mar 2011 12:32:03 -0500 Steve French…
Quoted 53 lines · Jeff Layton
Quoted 41 lines · On Wed, 23 Mar 2011 12:27:31 +0300 Pavel Shilovsky…

2011/3/23 Steve French <[email protected]>:

Quoted 9 lines

Pavel,
Jeff and I talked about invalidate_mapping and its uses this afternoon.  A few comments:
1)   Take a look at what happens on filemap_fdatawait call in invalidate_mapping to see if it makes sense to return errors through back to some of the callers of invalidate_mapping, in particular, strict_fsync.  If we can't write out the file data (ENOSPC, or host down etc.), we want to make sure that the return code gets sent back on any calls that can reasonably expect such an error.

vfs_fsync_range has already done filemap_fdatawait call - so, in this case there is no need to do it again in cifs_invalidate_mapping. The only reason for calling this is to invalidate_inode_pages2 but any error there shouldn't affect fsync behavior, as I think.

Quoted 7 lines

2) If invalidate_inode_pages2 fails (e.g. with EBUSY, because one of the pages couldn't be freed from the mapping because it just got redirtied right after we flushed it the line before) we set the mapping to invalid but don't check cifs_i->invalid_mapping
in many places.  Should we add checks for cifs_i->invalid_mapping in more places?

The one place where we should add such a check is read call, but it needs cifs_revalidate_file instead (that I am going to provide next) before generic_file_aio_read. In this case cifs_revalidate will check for invalid_mapping and needs to return a error if we could not invalidate all inode pages in cifs_invalidate_mapping (because it returns wrong data to the read call). But as you noticed lseek shouldn't think about this error and it uses cifs_revalidate_file too.

So, we may add extra check for -EBUSY error code in callers of cifs_revalidate_{dentry,file} and cifs_invaliadate_mapping and separate them into two groups:
1) that aware about -EBUSY error code and return a error the it's caller. these are: cifs_d_revalidate, cifs_file_aio_read (future implementation), cifs_file_strict_mmap.
2) that doesn't aware about it and return ok in this case. these are: cifs_getattrs, cifs_lseek, cifs_fsync.

Quoted 2 lines

Thoughts?

The main reason I think we need to reconsider that error is that I spent several months tracking down a rather nasty data corruption bug relating to mmap on NFS in RHEL5 a few years ago:

   https://bugzilla.redhat.com/show_bug.cgi?id=435291

Quoted 8 lines

Part of the problem there was that the NFS client ignored the return code from invalidate_inode_pages2. The other part of the problem was a lack of synchronization between mmap calls and the page fault handler.

Needless to say, this was not a fun problem to track down. I think you need to be very careful about ignoring errors from invalidate_inode_pages2 and think carefully about what a failure there means for all cases.

Quoted 5 lines

I agree - need to be careful, but IIRC the NFS problem would be that it has a launder_page method which is returning an error through invalidate_inode_pages2 while in the cifs case the data is forced to be written out through filemap_fdatawrite or filemap_write_and_wait.

Quoted 6 lines

No. RHEL5 at that time didn't have a launder page method (it does now, but that's another story).

--
Jeff Layton <[email protected]>

But what's about these two groups of calls? Are you agree with them?

Signature · 2 lines
Best regards,
Pavel Shilovsky.