Skip to contentSkip to conversation

GFS2: Use shorter form of zero_user_page() in code.

PATCH In review Robert P. J. Day 2 participants 4 messages Jul 10, 2007 – Jul 11, 2007 GFS2 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 GFS2: Use shorter form of zero_user_page() in code.

---

AFAICT, the following should be entirely equivalent, but shorter, based on the zero_user_page macro defined in highmem.h.

 fs/gfs2/bmap.c        |    6 ++----
 fs/gfs2/ops_address.c |    6 ++----
 2 files changed, 4 insertions(+), 8 deletions(-)
fs/gfs2/bmap.c +2 -4
index c53a5d2..8fd90b3 100644
@@ -14,6 +14,7 @@
 #include <linux/gfs2_ondisk.h>
 #include <linux/crc32.h>
 #include <linux/lm_interface.h>
+#include <linux/highmem.h>
 
 #include "gfs2.h"
 #include "incore.h"
@@ -933,10 +934,7 @@ static int gfs2_block_truncate_page(struct address_space *mapping)
 	if (sdp->sd_args.ar_data == GFS2_DATA_ORDERED || gfs2_is_jdata(ip))
 		gfs2_trans_add_bh(ip->i_gl, bh, 0);
 
-	kaddr = kmap_atomic(page, KM_USER0);
-	memset(kaddr + offset, 0, length);
-	flush_dcache_page(page);
-	kunmap_atomic(kaddr, KM_USER0);
+	zero_user_page(page, offset, length, KM_USER0);
 
 unlock:
 	unlock_page(page);
fs/gfs2/ops_address.c +2 -4
index 30c1562..d90ce06 100644
@@ -19,6 +19,7 @@
 #include <linux/writeback.h>
 #include <linux/gfs2_ondisk.h>
 #include <linux/lm_interface.h>
+#include <linux/highmem.h>
 
 #include "gfs2.h"
 #include "incore.h"
@@ -203,10 +204,7 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page)
 	 * so we need to supply one here. It doesn't happen often.
 	 */
 	if (unlikely(page->index)) {
-		kaddr = kmap_atomic(page, KM_USER0);
-		memset(kaddr, 0, PAGE_CACHE_SIZE);
-		kunmap_atomic(kaddr, KM_USER0);
-		flush_dcache_page(page);
+		zero_user_page(page, 0, PAGE_CACHE_SIZE, KM_USER0);
 		SetPageUptodate(page);
 		return 0;
 	}
Signature · 7 lines
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================
#1 lore raw

Hi,

I'll add this in as soon as Linus has pulled the current tree. Thanks,

Steve.

Quoted 60 lines · Robert P. J. Day

---

AFAICT, the following should be entirely equivalent, but shorter, based on the zero_user_page macro defined in highmem.h.

 fs/gfs2/bmap.c        |    6 ++----
 fs/gfs2/ops_address.c |    6 ++----
 2 files changed, 4 insertions(+), 8 deletions(-)
fs/gfs2/bmap.c +2 -4
index c53a5d2..8fd90b3 100644
@@ -14,6 +14,7 @@
 #include <linux/gfs2_ondisk.h>
 #include <linux/crc32.h>
 #include <linux/lm_interface.h>
+#include <linux/highmem.h>
 
 #include "gfs2.h"
 #include "incore.h"
@@ -933,10 +934,7 @@ static int gfs2_block_truncate_page(struct address_space *mapping)
 	if (sdp->sd_args.ar_data == GFS2_DATA_ORDERED || gfs2_is_jdata(ip))
 		gfs2_trans_add_bh(ip->i_gl, bh, 0);
 
-	kaddr = kmap_atomic(page, KM_USER0);
-	memset(kaddr + offset, 0, length);
-	flush_dcache_page(page);
-	kunmap_atomic(kaddr, KM_USER0);
+	zero_user_page(page, offset, length, KM_USER0);
 
 unlock:
 	unlock_page(page);
fs/gfs2/ops_address.c +2 -4
index 30c1562..d90ce06 100644
@@ -19,6 +19,7 @@
 #include <linux/writeback.h>
 #include <linux/gfs2_ondisk.h>
 #include <linux/lm_interface.h>
+#include <linux/highmem.h>
 
 #include "gfs2.h"
 #include "incore.h"
@@ -203,10 +204,7 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page)
 	 * so we need to supply one here. It doesn't happen often.
 	 */
 	if (unlikely(page->index)) {
-		kaddr = kmap_atomic(page, KM_USER0);
-		memset(kaddr, 0, PAGE_CACHE_SIZE);
-		kunmap_atomic(kaddr, KM_USER0);
-		flush_dcache_page(page);
+		zero_user_page(page, 0, PAGE_CACHE_SIZE, KM_USER0);
 		SetPageUptodate(page);
 		return 0;
 	}
#2 lore raw

Hi,

I just realised when I came to apply this patch that we already have these changes in the combination of Nate Diller's patch to bmap.c and my patch (at your suggestion) to ops_address.c so I think this is a duplicate,

Steve.

Quoted 68 lines · Steven Whitehouse

Hi,

I'll add this in as soon as Linus has pulled the current tree. Thanks,

Steve.

Quoted 60 lines · Robert P. J. Day

---

AFAICT, the following should be entirely equivalent, but shorter, based on the zero_user_page macro defined in highmem.h.

 fs/gfs2/bmap.c        |    6 ++----
 fs/gfs2/ops_address.c |    6 ++----
 2 files changed, 4 insertions(+), 8 deletions(-)
fs/gfs2/bmap.c +2 -4
index c53a5d2..8fd90b3 100644
@@ -14,6 +14,7 @@
 #include <linux/gfs2_ondisk.h>
 #include <linux/crc32.h>
 #include <linux/lm_interface.h>
+#include <linux/highmem.h>
 
 #include "gfs2.h"
 #include "incore.h"
@@ -933,10 +934,7 @@ static int gfs2_block_truncate_page(struct address_space *mapping)
 	if (sdp->sd_args.ar_data == GFS2_DATA_ORDERED || gfs2_is_jdata(ip))
 		gfs2_trans_add_bh(ip->i_gl, bh, 0);
 
-	kaddr = kmap_atomic(page, KM_USER0);
-	memset(kaddr + offset, 0, length);
-	flush_dcache_page(page);
-	kunmap_atomic(kaddr, KM_USER0);
+	zero_user_page(page, offset, length, KM_USER0);
 
 unlock:
 	unlock_page(page);
fs/gfs2/ops_address.c +2 -4
index 30c1562..d90ce06 100644
@@ -19,6 +19,7 @@
 #include <linux/writeback.h>
 #include <linux/gfs2_ondisk.h>
 #include <linux/lm_interface.h>
+#include <linux/highmem.h>
 
 #include "gfs2.h"
 #include "incore.h"
@@ -203,10 +204,7 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page)
 	 * so we need to supply one here. It doesn't happen often.
 	 */
 	if (unlikely(page->index)) {
-		kaddr = kmap_atomic(page, KM_USER0);
-		memset(kaddr, 0, PAGE_CACHE_SIZE);
-		kunmap_atomic(kaddr, KM_USER0);
-		flush_dcache_page(page);
+		zero_user_page(page, 0, PAGE_CACHE_SIZE, KM_USER0);
 		SetPageUptodate(page);
 		return 0;
 	}
#3 lore raw
Quoted 8 lines · Steven Whitehouse

Hi,

I just realised when I came to apply this patch that we already have these changes in the combination of Nate Diller's patch to bmap.c and my patch (at your suggestion) to ops_address.c so I think this is a duplicate,

Steve.

no problem, just toss it, then.

rday