Skip to contentSkip to conversation

9p: set page uptodate when required in write_end()

PATCH Applied [email protected] 3 participants 5 messages Apr 10, 2017 – Oct 11, 2017 9P file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 9p: set page uptodate when required in write_end()

From: Alexander Levin <[email protected]>

Commit 77469c3f570 prevented setting the page as uptodate when we wrote the right amount of data, fix that.

Fixes 77469c3f570 ("9p: saner ->write_end() on failing copy into non-uptodate page")
---
 fs/9p/vfs_addr.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
fs/9p/vfs_addr.c +7 -3
index adaf6f6..e1cbdfd 100644
@@ -310,9 +310,13 @@ static int v9fs_write_end(struct file *filp, struct address_space *mapping,
 
 	p9_debug(P9_DEBUG_VFS, "filp %p, mapping %p\n", filp, mapping);
 
-	if (unlikely(copied < len && !PageUptodate(page))) {
-		copied = 0;
-		goto out;
+	if (!PageUptodate(page)) {
+		if (unlikely(copied < len)) {
+			copied = 0;
+			goto out;
+		} else if (len == PAGE_SIZE) {
+			SetPageUptodate(page);
+		}
 	}
 	/*
 	 * No need to use i_size_read() here, the i_size
Signature · 1 line
2.7.4
#1 lore raw

Ping?

Quoted 35 lines · Sasha Levin

From: Alexander Levin <[email protected]>

Commit 77469c3f570 prevented setting the page as uptodate when we wrote the right amount of data, fix that.

Fixes 77469c3f570 ("9p: saner ->write_end() on failing copy into non-uptodate page")
---
 fs/9p/vfs_addr.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
fs/9p/vfs_addr.c +7 -3
index adaf6f6..e1cbdfd 100644
@@ -310,9 +310,13 @@ static int v9fs_write_end(struct file *filp, struct address_space *mapping,
 
 	p9_debug(P9_DEBUG_VFS, "filp %p, mapping %p\n", filp, mapping);
 
-	if (unlikely(copied < len && !PageUptodate(page))) {
-		copied = 0;
-		goto out;
+	if (!PageUptodate(page)) {
+		if (unlikely(copied < len)) {
+			copied = 0;
+			goto out;
+		} else if (len == PAGE_SIZE) {
+			SetPageUptodate(page);
+		}
 	}
 	/*
 	 * No need to use i_size_read() here, the i_size
Signature · 1 line
2.7.4
Signature · 2 lines
Thanks,
Sasha
#2 lore raw

Linus, Al,

Can one of you please pick this one directly?

This has been on LKML since April, but the 9p maintainers seem to be MIA?

Quoted 43 lines · Sasha Levin

Ping?

Quoted 35 lines · Sasha Levin

From: Alexander Levin <[email protected]>

Commit 77469c3f570 prevented setting the page as uptodate when we wrote the right amount of data, fix that.

Fixes 77469c3f570 ("9p: saner ->write_end() on failing copy into non-uptodate page")
---
 fs/9p/vfs_addr.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
fs/9p/vfs_addr.c +7 -4
index adaf6f6..e1cbdfd 100644
@@ -310,9 +310,13 @@ static int v9fs_write_end(struct file *filp, struct address_space *mapping,
 
 	p9_debug(P9_DEBUG_VFS, "filp %p, mapping %p\n", filp, mapping);
 
-	if (unlikely(copied < len && !PageUptodate(page))) {
-		copied = 0;
-		goto out;
+	if (!PageUptodate(page)) {
+		if (unlikely(copied < len)) {
+			copied = 0;
+			goto out;
+		} else if (len == PAGE_SIZE) {
+			SetPageUptodate(page);
+		}
 	}
 	/*
 	 * No need to use i_size_read() here, the i_size
--

2.7.4

Signature · 2 lines
Thanks,
Sasha
Signature · 2 lines
Thanks,
Sasha
#3 lore raw
Quoted 4 lines · Alexander (Sasha Levin)

Can one of you please pick this one directly?

This has been on LKML since April, but the 9p maintainers seem to be MIA?

Applied.

Thanks,

Linus

#4 lore raw
In reply to Levin, Alexander (Sasha Levin)
Quoted 8 lines · Alexander (Sasha Levin)
Quoted 8 lines
Quoted 8 lines
fs/9p/vfs_addr.c +0 -0
index adaf6f6..e1cbdfd 100644
@@ -310,9 +310,13 @@ static int v9fs_write_end(struct file *filp, struct address_space *mapping,
 
 	p9_debug(P9_DEBUG_VFS, "filp %p, mapping %p\n", filp, mapping);
 
Quoted 10 lines
Quoted 10 lines

fs/9p/vfs_addr.c static int v9fs_write_end(struct file *filp, struct address_space *mapping, · line 319

Quoted 10 lines
fs/9p/vfs_addr.c +7 -3
-	if (unlikely(copied < len && !PageUptodate(page))) {
-		copied = 0;
-		goto out;
+	if (!PageUptodate(page)) {
+		if (unlikely(copied < len)) {
+			copied = 0;
+			goto out;
+		} else if (len == PAGE_SIZE) {
+			SetPageUptodate(page);
+		}

Umm... I'm not sure I like it in that form. Look: to get here we need to successfully pass through ->write_begin(). Which means that we either have returned with PageUptodate(page) or had hit len == PAGE_SIZE && !PageUptodate(page). Case of non-uptodate with len < PAGE_SIZE is handled by forcing readpage and repeating the entire thing.

So the only way to get !PageUptodate(page) in ->write_end() is to have had len == PAGE_SIZE. It needs a comment, at the very least.