Skip to contentSkip to conversation

NFS: Use of mapping_set_error() results in spurious errors

PATCH New [email protected] 1 participant 2 messages Feb 15, 2022

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/2 NFS: Use of mapping_set_error() results in spurious errors

From: Trond Myklebust <[email protected]>

The use of mapping_set_error() in conjunction with calls to filemap_check_errors() is problematic because every error gets reported as either an EIO or an ENOSPC by filemap_check_errors() in functions such as filemap_write_and_wait() or filemap_write_and_wait_range(). In almost all cases, we prefer to use the more nuanced wb errors.

Fixes b8946d7bfb94 ("NFS: Revalidate the file mapping on all fatal writeback errors")
---
 fs/nfs/write.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/nfs/write.c +4 -1
index f88b0eb9b18e..74d258781205 100644
@@ -316,7 +316,10 @@ static void nfs_mapping_set_error(struct page *page, int error)
 	struct address_space *mapping = page_file_mapping(page);
 
 	SetPageError(page);
-	mapping_set_error(mapping, error);
+	filemap_set_wb_err(mapping, error);
+	if (mapping->host)
+		errseq_set(&mapping->host->i_sb->s_wb_err,
+			   error == -ENOSPC ? -ENOSPC : -EIO);
 	nfs_set_pageerror(mapping);
 }
 
Signature · 1 line
2.35.1
author maintainer
#1 lore raw

PATCH 2/2 NFS: Do not report writeback errors in nfs_getattr()

From: Trond Myklebust <[email protected]>

The result of the writeback, whether it is an ENOSPC or an EIO, or anything else, does not inhibit the NFS client from reporting the correct file timestamps.

Fixes 79566ef018f5 ("NFS: Getattr doesn't require data sync semantics")
---
 fs/nfs/inode.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
fs/nfs/inode.c +3 -6
index 90432fc389a0..f9fc506ebb29 100644
@@ -850,12 +850,9 @@ int nfs_getattr(struct user_namespace *mnt_userns, const struct path *path,
 	}
 
 	/* Flush out writes to the server in order to update c/mtime.  */
-	if ((request_mask & (STATX_CTIME|STATX_MTIME)) &&
-			S_ISREG(inode->i_mode)) {
-		err = filemap_write_and_wait(inode->i_mapping);
-		if (err)
-			goto out;
-	}
+	if ((request_mask & (STATX_CTIME | STATX_MTIME)) &&
+	    S_ISREG(inode->i_mode))
+		filemap_write_and_wait(inode->i_mapping);
 
 	/*
 	 * We may force a getattr if the user cares about atime.
Signature · 1 line
2.35.1