Skip to content

Commit 7a607a4

Browse files
author
Andreas Gruenbacher
committed
gfs2: Clean up gfs2_unstuff_dinode
Split __gfs2_unstuff_inode off from gfs2_unstuff_dinode and clean up the code a little. All remaining callers now pass NULL as the page argument of gfs2_unstuff_dinode, so remove that argument. Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent 64090cb commit 7a607a4

File tree

5 files changed

+36
-36
lines changed

5 files changed

+36
-36
lines changed

fs/gfs2/bmap.c

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,6 @@ static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh,
5656
u64 block, struct page *page)
5757
{
5858
struct inode *inode = &ip->i_inode;
59-
int release = 0;
60-
61-
if (!page || page->index) {
62-
page = find_or_create_page(inode->i_mapping, 0, GFP_NOFS);
63-
if (!page)
64-
return -ENOMEM;
65-
release = 1;
66-
}
6759

6860
if (!PageUptodate(page)) {
6961
void *kaddr = kmap(page);
@@ -97,38 +89,20 @@ static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh,
9789
gfs2_ordered_add_inode(ip);
9890
}
9991

100-
if (release) {
101-
unlock_page(page);
102-
put_page(page);
103-
}
104-
10592
return 0;
10693
}
10794

108-
/**
109-
* gfs2_unstuff_dinode - Unstuff a dinode when the data has grown too big
110-
* @ip: The GFS2 inode to unstuff
111-
* @page: The (optional) page. This is looked up if the @page is NULL
112-
*
113-
* This routine unstuffs a dinode and returns it to a "normal" state such
114-
* that the height can be grown in the traditional way.
115-
*
116-
* Returns: errno
117-
*/
118-
119-
int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page)
95+
static int __gfs2_unstuff_inode(struct gfs2_inode *ip, struct page *page)
12096
{
12197
struct buffer_head *bh, *dibh;
12298
struct gfs2_dinode *di;
12399
u64 block = 0;
124100
int isdir = gfs2_is_dir(ip);
125101
int error;
126102

127-
down_write(&ip->i_rw_mutex);
128-
129103
error = gfs2_meta_inode_buffer(ip, &dibh);
130104
if (error)
131-
goto out;
105+
return error;
132106

133107
if (i_size_read(&ip->i_inode)) {
134108
/* Get a free block, fill it with the stuffed data,
@@ -170,12 +144,38 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page)
170144

171145
out_brelse:
172146
brelse(dibh);
147+
return error;
148+
}
149+
150+
/**
151+
* gfs2_unstuff_dinode - Unstuff a dinode when the data has grown too big
152+
* @ip: The GFS2 inode to unstuff
153+
*
154+
* This routine unstuffs a dinode and returns it to a "normal" state such
155+
* that the height can be grown in the traditional way.
156+
*
157+
* Returns: errno
158+
*/
159+
160+
int gfs2_unstuff_dinode(struct gfs2_inode *ip)
161+
{
162+
struct inode *inode = &ip->i_inode;
163+
struct page *page;
164+
int error;
165+
166+
down_write(&ip->i_rw_mutex);
167+
page = find_or_create_page(inode->i_mapping, 0, GFP_NOFS);
168+
error = -ENOMEM;
169+
if (!page)
170+
goto out;
171+
error = __gfs2_unstuff_inode(ip, page);
172+
unlock_page(page);
173+
put_page(page);
173174
out:
174175
up_write(&ip->i_rw_mutex);
175176
return error;
176177
}
177178

178-
179179
/**
180180
* find_metapath - Find path through the metadata tree
181181
* @sdp: The superblock
@@ -1079,7 +1079,7 @@ static int gfs2_iomap_begin_write(struct inode *inode, loff_t pos,
10791079
goto out_trans_fail;
10801080

10811081
if (unstuff) {
1082-
ret = gfs2_unstuff_dinode(ip, NULL);
1082+
ret = gfs2_unstuff_dinode(ip);
10831083
if (ret)
10841084
goto out_trans_end;
10851085
release_metapath(mp);
@@ -2143,7 +2143,7 @@ static int do_grow(struct inode *inode, u64 size)
21432143
goto do_grow_release;
21442144

21452145
if (unstuff) {
2146-
error = gfs2_unstuff_dinode(ip, NULL);
2146+
error = gfs2_unstuff_dinode(ip);
21472147
if (error)
21482148
goto do_end_trans;
21492149
}

fs/gfs2/bmap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static inline void gfs2_write_calc_reserv(const struct gfs2_inode *ip,
4646
extern const struct iomap_ops gfs2_iomap_ops;
4747
extern const struct iomap_writeback_ops gfs2_writeback_ops;
4848

49-
extern int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page);
49+
extern int gfs2_unstuff_dinode(struct gfs2_inode *ip);
5050
extern int gfs2_block_map(struct inode *inode, sector_t lblock,
5151
struct buffer_head *bh, int create);
5252
extern int gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length,

fs/gfs2/dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ static int gfs2_dir_write_data(struct gfs2_inode *ip, const char *buf,
172172
return -EINVAL;
173173

174174
if (gfs2_is_stuffed(ip)) {
175-
error = gfs2_unstuff_dinode(ip, NULL);
175+
error = gfs2_unstuff_dinode(ip);
176176
if (error)
177177
return error;
178178
}

fs/gfs2/file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ static vm_fault_t gfs2_page_mkwrite(struct vm_fault *vmf)
512512

513513
/* Unstuff, if required, and allocate backing blocks for page */
514514
if (gfs2_is_stuffed(ip)) {
515-
err = gfs2_unstuff_dinode(ip, NULL);
515+
err = gfs2_unstuff_dinode(ip);
516516
if (err) {
517517
ret = block_page_mkwrite_return(err);
518518
goto out_trans_end;
@@ -981,7 +981,7 @@ static int fallocate_chunk(struct inode *inode, loff_t offset, loff_t len,
981981
gfs2_trans_add_meta(ip->i_gl, dibh);
982982

983983
if (gfs2_is_stuffed(ip)) {
984-
error = gfs2_unstuff_dinode(ip, NULL);
984+
error = gfs2_unstuff_dinode(ip);
985985
if (unlikely(error))
986986
goto out;
987987
}

fs/gfs2/quota.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ static int gfs2_adjust_quota(struct gfs2_inode *ip, loff_t loc,
825825
u64 size;
826826

827827
if (gfs2_is_stuffed(ip)) {
828-
err = gfs2_unstuff_dinode(ip, NULL);
828+
err = gfs2_unstuff_dinode(ip);
829829
if (err)
830830
return err;
831831
}

0 commit comments

Comments
 (0)