]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
[GFS2] Tidy gfs2_unstuffer_page
authorSteven Whitehouse <swhiteho@redhat.com>
Wed, 26 Jul 2006 14:51:20 +0000 (10:51 -0400)
committerSteven Whitehouse <swhiteho@redhat.com>
Wed, 26 Jul 2006 14:51:20 +0000 (10:51 -0400)
Tidy up gfs2_unstuffer_page by:

 a) Moving it into bmap.c
 b) Making it static
 c) Calling it directly from gfs2_unstuff_dinode
 d) Updating all callers of gfs2_unstuff_dinode due to one less
    required argument.

It doesn't change the behaviour at all.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
fs/gfs2/bmap.c
fs/gfs2/bmap.h
fs/gfs2/dir.c
fs/gfs2/ops_address.c
fs/gfs2/ops_vm.c
fs/gfs2/page.c
fs/gfs2/page.h

index 98fa07c2b710ee6db00c5a1942638550d430474d..72b19c5d7807f644de6afe59e354ba261ab2434d 100644 (file)
@@ -47,6 +47,65 @@ struct strip_mine {
        unsigned int sm_height;
 };
 
+/**
+ * gfs2_unstuffer_page - unstuff a stuffed inode into a block cached by a page
+ * @ip: the inode
+ * @dibh: the dinode buffer
+ * @block: the block number that was allocated
+ * @private: any locked page held by the caller process
+ *
+ * Returns: errno
+ */
+
+static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh,
+                              uint64_t block, struct page *page)
+{
+       struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
+       struct inode *inode = &ip->i_inode;
+       struct buffer_head *bh;
+       int release = 0;
+
+       if (!page || page->index) {
+               page = grab_cache_page(inode->i_mapping, 0);
+               if (!page)
+                       return -ENOMEM;
+               release = 1;
+       }
+
+       if (!PageUptodate(page)) {
+               void *kaddr = kmap(page);
+
+               memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode),
+                      ip->i_di.di_size);
+               memset(kaddr + ip->i_di.di_size, 0,
+                      PAGE_CACHE_SIZE - ip->i_di.di_size);
+               kunmap(page);
+
+               SetPageUptodate(page);
+       }
+
+       if (!page_has_buffers(page))
+               create_empty_buffers(page, 1 << inode->i_blkbits,
+                                    (1 << BH_Uptodate));
+
+       bh = page_buffers(page);
+
+       if (!buffer_mapped(bh))
+               map_bh(bh, inode->i_sb, block);
+
+       set_buffer_uptodate(bh);
+       if ((sdp->sd_args.ar_data == GFS2_DATA_ORDERED) || gfs2_is_jdata(ip))
+               gfs2_trans_add_bh(ip->i_gl, bh, 0);
+       mark_buffer_dirty(bh);
+
+       if (release) {
+               unlock_page(page);
+               page_cache_release(page);
+       }
+
+       return 0;
+}
+
 /**
  * gfs2_unstuff_dinode - Unstuff a dinode when the data has grown too big
  * @ip: The GFS2 inode to unstuff
@@ -59,8 +118,7 @@ struct strip_mine {
  * Returns: errno
  */
 
-int gfs2_unstuff_dinode(struct gfs2_inode *ip, gfs2_unstuffer_t unstuffer,
-                       void *private)
+int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page)
 {
        struct buffer_head *bh, *dibh;
        uint64_t block = 0;
@@ -90,7 +148,7 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, gfs2_unstuffer_t unstuffer,
                } else {
                        block = gfs2_alloc_data(ip);
 
-                       error = unstuffer(ip, dibh, block, private);
+                       error = gfs2_unstuffer_page(ip, dibh, block, page);
                        if (error)
                                goto out_brelse;
                }
@@ -786,8 +844,7 @@ static int do_grow(struct gfs2_inode *ip, uint64_t size)
 
        if (size > sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode)) {
                if (gfs2_is_stuffed(ip)) {
-                       error = gfs2_unstuff_dinode(ip, gfs2_unstuffer_page,
-                                                   NULL);
+                       error = gfs2_unstuff_dinode(ip, NULL);
                        if (error)
                                goto out_end_trans;
                }
index 06ccb2d808ad947303630a5f1a0ddced38890ff6..1a265412f7eef79e9568ae95f1d2004341015bb6 100644 (file)
 #ifndef __BMAP_DOT_H__
 #define __BMAP_DOT_H__
 
-typedef int (*gfs2_unstuffer_t) (struct gfs2_inode * ip,
-                                struct buffer_head * dibh, uint64_t block,
-                                void *private);
-int gfs2_unstuff_dinode(struct gfs2_inode *ip, gfs2_unstuffer_t unstuffer,
-                       void *private);
-
+int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page);
 int gfs2_block_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, int *boundary);
 int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsigned *extlen);
 
index f62223b9e53d048add9a5446dba6e2b4263672b0..563b99e419b6bd5574f7ee2b963d095531c25e91 100644 (file)
@@ -173,7 +173,7 @@ static int gfs2_dir_write_data(struct gfs2_inode *ip, const char *buf,
                return -EINVAL;
 
        if (gfs2_is_stuffed(ip)) {
-               error = gfs2_unstuff_dinode(ip, NULL, NULL);
+               error = gfs2_unstuff_dinode(ip, NULL);
                if (error)
                        return error;
        }
index d33f6aa79731170a85c4a470f990e401341c5b89..93e00a8af8cf274235faf2f03f69044c34939523 100644 (file)
@@ -395,8 +395,7 @@ static int gfs2_prepare_write(struct file *file, struct page *page,
 
        if (gfs2_is_stuffed(ip)) {
                if (end > sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode)) {
-                       error = gfs2_unstuff_dinode(ip, gfs2_unstuffer_page,
-                                                   page);
+                       error = gfs2_unstuff_dinode(ip, page);
                        if (error == 0)
                                goto prepare_write;
                } else if (!PageUptodate(page))
index 08709f19ea9804c0f6d4f9c56e73f182dbd80405..910722d4c483e8fd49cb61a60ca300384b589c04 100644 (file)
@@ -104,7 +104,7 @@ static int alloc_page_backing(struct gfs2_inode *ip, struct page *page)
                goto out_ipres;
 
        if (gfs2_is_stuffed(ip)) {
-               error = gfs2_unstuff_dinode(ip, gfs2_unstuffer_page, NULL);
+               error = gfs2_unstuff_dinode(ip, NULL);
                if (error)
                        goto out_trans;
        }
index b93caf294b9f49e7e6429bf2fcc3cb3e3d42acdb..0d6befed1ae54c39312c0e683925caf0c7b454a0 100644 (file)
@@ -113,66 +113,6 @@ void gfs2_page_sync(struct gfs2_glock *gl, int flags)
 
 }
 
-/**
- * gfs2_unstuffer_page - unstuff a stuffed inode into a block cached by a page
- * @ip: the inode
- * @dibh: the dinode buffer
- * @block: the block number that was allocated
- * @private: any locked page held by the caller process
- *
- * Returns: errno
- */
-
-int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh,
-                       uint64_t block, void *private)
-{
-       struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
-       struct inode *inode = &ip->i_inode;
-       struct page *page = (struct page *)private;
-       struct buffer_head *bh;
-       int release = 0;
-
-       if (!page || page->index) {
-               page = grab_cache_page(inode->i_mapping, 0);
-               if (!page)
-                       return -ENOMEM;
-               release = 1;
-       }
-
-       if (!PageUptodate(page)) {
-               void *kaddr = kmap(page);
-
-               memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode),
-                      ip->i_di.di_size);
-               memset(kaddr + ip->i_di.di_size, 0,
-                      PAGE_CACHE_SIZE - ip->i_di.di_size);
-               kunmap(page);
-
-               SetPageUptodate(page);
-       }
-
-       if (!page_has_buffers(page))
-               create_empty_buffers(page, 1 << inode->i_blkbits,
-                                    (1 << BH_Uptodate));
-
-       bh = page_buffers(page);
-
-       if (!buffer_mapped(bh))
-               map_bh(bh, inode->i_sb, block);
-
-       set_buffer_uptodate(bh);
-       if ((sdp->sd_args.ar_data == GFS2_DATA_ORDERED) || gfs2_is_jdata(ip))
-               gfs2_trans_add_bh(ip->i_gl, bh, 0);
-       mark_buffer_dirty(bh);
-
-       if (release) {
-               unlock_page(page);
-               page_cache_release(page);
-       }
-
-       return 0;
-}
-
 /**
  * gfs2_block_truncate_page - Deal with zeroing out data for truncate
  *
index 2c853a90ac04fe07145593bbf94318b781b2e277..67a4f4b79aa6c5bde726704f3e3868a5119c2c97 100644 (file)
@@ -14,8 +14,6 @@ void gfs2_pte_inval(struct gfs2_glock *gl);
 void gfs2_page_inval(struct gfs2_glock *gl);
 void gfs2_page_sync(struct gfs2_glock *gl, int flags);
 
-int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh,
-                       uint64_t block, void *private);
 int gfs2_block_truncate_page(struct address_space *mapping);
 void gfs2_page_add_databufs(struct gfs2_inode *ip, struct page *page,
                            unsigned int from, unsigned int to);