@@ -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
171145out_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 );
173174out :
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 }
0 commit comments