@@ -56,14 +56,6 @@ static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh,
56
56
u64 block , struct page * page )
57
57
{
58
58
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
- }
67
59
68
60
if (!PageUptodate (page )) {
69
61
void * kaddr = kmap (page );
@@ -97,38 +89,20 @@ static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh,
97
89
gfs2_ordered_add_inode (ip );
98
90
}
99
91
100
- if (release ) {
101
- unlock_page (page );
102
- put_page (page );
103
- }
104
-
105
92
return 0 ;
106
93
}
107
94
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 )
120
96
{
121
97
struct buffer_head * bh , * dibh ;
122
98
struct gfs2_dinode * di ;
123
99
u64 block = 0 ;
124
100
int isdir = gfs2_is_dir (ip );
125
101
int error ;
126
102
127
- down_write (& ip -> i_rw_mutex );
128
-
129
103
error = gfs2_meta_inode_buffer (ip , & dibh );
130
104
if (error )
131
- goto out ;
105
+ return error ;
132
106
133
107
if (i_size_read (& ip -> i_inode )) {
134
108
/* 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)
170
144
171
145
out_brelse :
172
146
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 );
173
174
out :
174
175
up_write (& ip -> i_rw_mutex );
175
176
return error ;
176
177
}
177
178
178
-
179
179
/**
180
180
* find_metapath - Find path through the metadata tree
181
181
* @sdp: The superblock
@@ -1079,7 +1079,7 @@ static int gfs2_iomap_begin_write(struct inode *inode, loff_t pos,
1079
1079
goto out_trans_fail ;
1080
1080
1081
1081
if (unstuff ) {
1082
- ret = gfs2_unstuff_dinode (ip , NULL );
1082
+ ret = gfs2_unstuff_dinode (ip );
1083
1083
if (ret )
1084
1084
goto out_trans_end ;
1085
1085
release_metapath (mp );
@@ -2143,7 +2143,7 @@ static int do_grow(struct inode *inode, u64 size)
2143
2143
goto do_grow_release ;
2144
2144
2145
2145
if (unstuff ) {
2146
- error = gfs2_unstuff_dinode (ip , NULL );
2146
+ error = gfs2_unstuff_dinode (ip );
2147
2147
if (error )
2148
2148
goto do_end_trans ;
2149
2149
}
0 commit comments