Skip to contentSkip to conversation

fs/fuse/dev.c: use zero_user_page instead

PATCH In review Denis Cheng 2 participants 4 messages Jul 20, 2007 FUSE filesystem core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/fuse/dev.c: use zero_user_page instead

---
I'm not very sure zero_user_page is correctly used here, so please feel free to give comments.

and why here it uses KM_USER1 not KM_USER0, What are the differences?

 fs/fuse/dev.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
fs/fuse/dev.c +3 -5
index 3ad22be..e55b5e8 100644
@@ -533,11 +533,9 @@ static int fuse_copy_do(struct fuse_copy_state *cs, void **val, unsigned *size)
 static int fuse_copy_page(struct fuse_copy_state *cs, struct page *page,
 			  unsigned offset, unsigned count, int zeroing)
 {
-	if (page && zeroing && count < PAGE_SIZE) {
-		void *mapaddr = kmap_atomic(page, KM_USER1);
-		memset(mapaddr, 0, PAGE_SIZE);
-		kunmap_atomic(mapaddr, KM_USER1);
-	}
+	if (page && zeroing && count < PAGE_SIZE)
+		zero_user_page(page, 0, PAGE_SIZE, KM_USER1);
+
 	while (count) {
 		int err;
 		if (!cs->len && (err = fuse_copy_fill(cs)))
Signature · 1 line
1.5.2.2
#1 lore raw
Quoted 16 lines · Denis Cheng

---
I'm not very sure zero_user_page is correctly used here, so please feel free to give comments.

and why here it uses KM_USER1 not KM_USER0, What are the differences?

 fs/fuse/dev.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
fs/fuse/dev.c +0 -0
index 3ad22be..e55b5e8 100644

fs/fuse/dev.c static int fuse_copy_do(struct fuse_copy_state *cs, void **val, unsigned *size) · line 537

Quoted 10 lines
fs/fuse/dev.c +2 -5
@@ -533,11 +533,9 @@ static int fuse_copy_do(struct fuse_copy_state *cs, void **val, unsigned *size)
 static int fuse_copy_page(struct fuse_copy_state *cs, struct page *page,
                          unsigned offset, unsigned count, int zeroing)
 {
-       if (page && zeroing && count < PAGE_SIZE) {
-               void *mapaddr = kmap_atomic(page, KM_USER1);
-               memset(mapaddr, 0, PAGE_SIZE);
-               kunmap_atomic(mapaddr, KM_USER1);
-       }
+       if (page && zeroing && count < PAGE_SIZE)
+               zero_user_page(page, 0, PAGE_SIZE, KM_USER1);

Why clear all page? IMHO,only count bytes need to be cleared.

Quoted 4 lines
fs/fuse/dev.c +1 -0
+
        while (count) {
                int err;
                if (!cs->len && (err = fuse_copy_fill(cs)))
author
#2 lore raw
Quoted 8 lines · Dave Young

fs/fuse/dev.c static int fuse_copy_do(struct fuse_copy_state *cs, void **val, unsigned *size) · line 537

Quoted 7 lines
fs/fuse/dev.c +2 -5
-       if (page && zeroing && count < PAGE_SIZE) {
-               void *mapaddr = kmap_atomic(page, KM_USER1);
-               memset(mapaddr, 0, PAGE_SIZE);
-               kunmap_atomic(mapaddr, KM_USER1);
-       }
+       if (page && zeroing && count < PAGE_SIZE)
+               zero_user_page(page, 0, PAGE_SIZE, KM_USER1);

Why clear all page? IMHO,only count bytes need to be cleared.

The original one is memset(mapaddr, 0, PAGE_SIZE), namely clear the whole page.

Signature · 5 lines
Denis Cheng
Linux Application Developer

"One of my most productive days was throwing away 1000 lines of code."
- Ken Thompson.
#3 lore raw
Quoted 11 lines · rae l
Quoted 8 lines · Dave Young

fs/fuse/dev.c static int fuse_copy_do(struct fuse_copy_state *cs, void **val, unsigned *size) · line 537

Quoted 7 lines
fs/fuse/dev.c +2 -5
-       if (page && zeroing && count < PAGE_SIZE) {
-               void *mapaddr = kmap_atomic(page, KM_USER1);
-               memset(mapaddr, 0, PAGE_SIZE);
-               kunmap_atomic(mapaddr, KM_USER1);
-       }
+       if (page && zeroing && count < PAGE_SIZE)
+               zero_user_page(page, 0, PAGE_SIZE, KM_USER1);

Why clear all page? IMHO,only count bytes need to be cleared.

The original one is memset(mapaddr, 0, PAGE_SIZE), namely clear the whole page.

Yes, I have same suspicion with original code.

Quoted 8 lines

--
Denis Cheng
Linux Application Developer

"One of my most productive days was throwing away 1000 lines of code."
- Ken Thompson.