Skip to contentSkip to conversation

orangefs: use folio_pos() and folio_size() in orangefs_page_mkwrite()

PATCH In review Tal Zussman 3 participants 4 messages Aug 9 – Aug 14

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

PATCH 1/1 orangefs: use folio_pos() and folio_size() in orangefs_page_mkwrite()

orangefs_page_mkwrite() records the faulted range with page_offset(vmf->page) and PAGE_SIZE, although the write range it sets is attached to the folio and the rest of the function already operates on folios. Use folio_pos() and folio_size() instead. This gets rid of two calls to page_offset(), removing two calls to compound_head().

No functional change. orangefs folios are always order-0, so the values are identical. However, if orangefs ever enables large folios, this change is necessary for correctness with the current write range tracking scheme. Tracking only a single page of a larger folio would leave the rest of the folio's dirty data outside the range that gets written back, leading to data loss.

---
 fs/orangefs/inode.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
fs/orangefs/inode.c +4 -4
index 7143b64b5b25..cd3273c88e03 100644
@@ -652,8 +652,8 @@ vm_fault_t orangefs_page_mkwrite(struct vm_fault *vmf)
 		wr = folio_get_private(folio);
 		if (uid_eq(wr->uid, current_fsuid()) &&
 		    gid_eq(wr->gid, current_fsgid())) {
-			wr->pos = page_offset(vmf->page);
-			wr->len = PAGE_SIZE;
+			wr->pos = folio_pos(folio);
+			wr->len = folio_size(folio);
 			goto okay;
 		} else {
 			if (orangefs_launder_folio(folio)) {
@@ -667,8 +667,8 @@ vm_fault_t orangefs_page_mkwrite(struct vm_fault *vmf)
 		ret = VM_FAULT_LOCKED|VM_FAULT_RETRY;
 		goto out;
 	}
-	wr->pos = page_offset(vmf->page);
-	wr->len = PAGE_SIZE;
+	wr->pos = folio_pos(folio);
+	wr->len = folio_size(folio);
 	wr->uid = current_fsuid();
 	wr->gid = current_fsgid();
 	folio_attach_private(folio, wr);

---
base-commit: 075b74841bd0065a3bda3440873c747938e69b68
change-id: 20260809-orangefs-mkwrite-folio-ec562f7625b4

Best regards,

Signature · 1 line
Tal Zussman <[email protected]>
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Tal Zussman

orangefs_page_mkwrite() records the faulted range with page_offset(vmf->page) and PAGE_SIZE, although the write range it sets is attached to the folio and the rest of the function already operates on folios. Use folio_pos() and folio_size() instead. This gets rid of two calls to page_offset(), removing two calls to compound_head().

Quoted 6 lines

No functional change. orangefs folios are always order-0, so the values are identical. However, if orangefs ever enables large folios, this change is necessary for correctness with the current write range tracking scheme. Tracking only a single page of a larger folio would leave the rest of the folio's dirty data outside the range that gets written back, leading to data loss.

Yeah, I agree.

maintainer
#2 lore raw
In reply to Tal Zussman

Thanks! I'm trying to finish up some stuff to get on linux-next in time, I'll let you know when I've run your patch through xfstests...

-Mike

Quoted 54 lines · Tal Zussman

orangefs_page_mkwrite() records the faulted range with page_offset(vmf->page) and PAGE_SIZE, although the write range it sets is attached to the folio and the rest of the function already operates on folios. Use folio_pos() and folio_size() instead. This gets rid of two calls to page_offset(), removing two calls to compound_head().

No functional change. orangefs folios are always order-0, so the values are identical. However, if orangefs ever enables large folios, this change is necessary for correctness with the current write range tracking scheme. Tracking only a single page of a larger folio would leave the rest of the folio's dirty data outside the range that gets written back, leading to data loss.

---
 fs/orangefs/inode.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
fs/orangefs/inode.c +4 -5
index 7143b64b5b25..cd3273c88e03 100644
@@ -652,8 +652,8 @@ vm_fault_t orangefs_page_mkwrite(struct vm_fault *vmf)
                wr = folio_get_private(folio);
                if (uid_eq(wr->uid, current_fsuid()) &&
                    gid_eq(wr->gid, current_fsgid())) {
-                       wr->pos = page_offset(vmf->page);
-                       wr->len = PAGE_SIZE;
+                       wr->pos = folio_pos(folio);
+                       wr->len = folio_size(folio);
                        goto okay;
                } else {
                        if (orangefs_launder_folio(folio)) {
@@ -667,8 +667,8 @@ vm_fault_t orangefs_page_mkwrite(struct vm_fault *vmf)
                ret = VM_FAULT_LOCKED|VM_FAULT_RETRY;
                goto out;
        }
-       wr->pos = page_offset(vmf->page);
-       wr->len = PAGE_SIZE;
+       wr->pos = folio_pos(folio);
+       wr->len = folio_size(folio);
        wr->uid = current_fsuid();
        wr->gid = current_fsgid();
        folio_attach_private(folio, wr);
 
---

base-commit: 075b74841bd0065a3bda3440873c747938e69b68
change-id: 20260809-orangefs-mkwrite-folio-ec562f7625b4

Best regards,
--
Tal Zussman <[email protected]>

maintainer
#3 lore raw

This patch is in my linux-next, thanks!

-Mike

Quoted 62 lines · Mike Marshall

Thanks! I'm trying to finish up some stuff to get on linux-next in time, I'll let you know when I've run your patch through xfstests...

-Mike

Quoted 54 lines · Tal Zussman

orangefs_page_mkwrite() records the faulted range with page_offset(vmf->page) and PAGE_SIZE, although the write range it sets is attached to the folio and the rest of the function already operates on folios. Use folio_pos() and folio_size() instead. This gets rid of two calls to page_offset(), removing two calls to compound_head().

No functional change. orangefs folios are always order-0, so the values are identical. However, if orangefs ever enables large folios, this change is necessary for correctness with the current write range tracking scheme. Tracking only a single page of a larger folio would leave the rest of the folio's dirty data outside the range that gets written back, leading to data loss.

---
 fs/orangefs/inode.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
fs/orangefs/inode.c +4 -5
index 7143b64b5b25..cd3273c88e03 100644
@@ -652,8 +652,8 @@ vm_fault_t orangefs_page_mkwrite(struct vm_fault *vmf)
                wr = folio_get_private(folio);
                if (uid_eq(wr->uid, current_fsuid()) &&
                    gid_eq(wr->gid, current_fsgid())) {
-                       wr->pos = page_offset(vmf->page);
-                       wr->len = PAGE_SIZE;
+                       wr->pos = folio_pos(folio);
+                       wr->len = folio_size(folio);
                        goto okay;
                } else {
                        if (orangefs_launder_folio(folio)) {
@@ -667,8 +667,8 @@ vm_fault_t orangefs_page_mkwrite(struct vm_fault *vmf)
                ret = VM_FAULT_LOCKED|VM_FAULT_RETRY;
                goto out;
        }
-       wr->pos = page_offset(vmf->page);
-       wr->len = PAGE_SIZE;
+       wr->pos = folio_pos(folio);
+       wr->len = folio_size(folio);
        wr->uid = current_fsuid();
        wr->gid = current_fsgid();
        folio_attach_private(folio, wr);
 
---

base-commit: 075b74841bd0065a3bda3440873c747938e69b68
change-id: 20260809-orangefs-mkwrite-folio-ec562f7625b4

Best regards,
--
Tal Zussman <[email protected]>