diff options
Diffstat (limited to 'fs/gfs2/ops_address.c')
-rw-r--r-- | fs/gfs2/ops_address.c | 52 |
1 files changed, 21 insertions, 31 deletions
diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c index 015640b3f123..d8d69a72a10d 100644 --- a/fs/gfs2/ops_address.c +++ b/fs/gfs2/ops_address.c | |||
@@ -156,19 +156,6 @@ out_ignore: | |||
156 | return 0; | 156 | return 0; |
157 | } | 157 | } |
158 | 158 | ||
159 | static int zero_readpage(struct page *page) | ||
160 | { | ||
161 | void *kaddr; | ||
162 | |||
163 | kaddr = kmap_atomic(page, KM_USER0); | ||
164 | memset(kaddr, 0, PAGE_CACHE_SIZE); | ||
165 | kunmap_atomic(kaddr, KM_USER0); | ||
166 | |||
167 | SetPageUptodate(page); | ||
168 | |||
169 | return 0; | ||
170 | } | ||
171 | |||
172 | /** | 159 | /** |
173 | * stuffed_readpage - Fill in a Linux page with stuffed file data | 160 | * stuffed_readpage - Fill in a Linux page with stuffed file data |
174 | * @ip: the inode | 161 | * @ip: the inode |
@@ -183,9 +170,7 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page) | |||
183 | void *kaddr; | 170 | void *kaddr; |
184 | int error; | 171 | int error; |
185 | 172 | ||
186 | /* Only the first page of a stuffed file might contain data */ | 173 | BUG_ON(page->index); |
187 | if (unlikely(page->index)) | ||
188 | return zero_readpage(page); | ||
189 | 174 | ||
190 | error = gfs2_meta_inode_buffer(ip, &dibh); | 175 | error = gfs2_meta_inode_buffer(ip, &dibh); |
191 | if (error) | 176 | if (error) |
@@ -230,9 +215,9 @@ static int gfs2_readpage(struct file *file, struct page *page) | |||
230 | /* gfs2_sharewrite_nopage has grabbed the ip->i_gl already */ | 215 | /* gfs2_sharewrite_nopage has grabbed the ip->i_gl already */ |
231 | goto skip_lock; | 216 | goto skip_lock; |
232 | } | 217 | } |
233 | gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME|GL_AOP, &gh); | 218 | gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME|LM_FLAG_TRY_1CB, &gh); |
234 | do_unlock = 1; | 219 | do_unlock = 1; |
235 | error = gfs2_glock_nq_m_atime(1, &gh); | 220 | error = gfs2_glock_nq_atime(&gh); |
236 | if (unlikely(error)) | 221 | if (unlikely(error)) |
237 | goto out_unlock; | 222 | goto out_unlock; |
238 | } | 223 | } |
@@ -254,6 +239,8 @@ skip_lock: | |||
254 | out: | 239 | out: |
255 | return error; | 240 | return error; |
256 | out_unlock: | 241 | out_unlock: |
242 | if (error == GLR_TRYFAILED) | ||
243 | error = AOP_TRUNCATED_PAGE; | ||
257 | unlock_page(page); | 244 | unlock_page(page); |
258 | if (do_unlock) | 245 | if (do_unlock) |
259 | gfs2_holder_uninit(&gh); | 246 | gfs2_holder_uninit(&gh); |
@@ -293,9 +280,9 @@ static int gfs2_readpages(struct file *file, struct address_space *mapping, | |||
293 | goto skip_lock; | 280 | goto skip_lock; |
294 | } | 281 | } |
295 | gfs2_holder_init(ip->i_gl, LM_ST_SHARED, | 282 | gfs2_holder_init(ip->i_gl, LM_ST_SHARED, |
296 | LM_FLAG_TRY_1CB|GL_ATIME|GL_AOP, &gh); | 283 | LM_FLAG_TRY_1CB|GL_ATIME, &gh); |
297 | do_unlock = 1; | 284 | do_unlock = 1; |
298 | ret = gfs2_glock_nq_m_atime(1, &gh); | 285 | ret = gfs2_glock_nq_atime(&gh); |
299 | if (ret == GLR_TRYFAILED) | 286 | if (ret == GLR_TRYFAILED) |
300 | goto out_noerror; | 287 | goto out_noerror; |
301 | if (unlikely(ret)) | 288 | if (unlikely(ret)) |
@@ -366,10 +353,13 @@ static int gfs2_prepare_write(struct file *file, struct page *page, | |||
366 | unsigned int write_len = to - from; | 353 | unsigned int write_len = to - from; |
367 | 354 | ||
368 | 355 | ||
369 | gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_ATIME|GL_AOP, &ip->i_gh); | 356 | gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_ATIME|LM_FLAG_TRY_1CB, &ip->i_gh); |
370 | error = gfs2_glock_nq_m_atime(1, &ip->i_gh); | 357 | error = gfs2_glock_nq_atime(&ip->i_gh); |
371 | if (error) | 358 | if (unlikely(error)) { |
359 | if (error == GLR_TRYFAILED) | ||
360 | error = AOP_TRUNCATED_PAGE; | ||
372 | goto out_uninit; | 361 | goto out_uninit; |
362 | } | ||
373 | 363 | ||
374 | gfs2_write_calc_reserv(ip, write_len, &data_blocks, &ind_blocks); | 364 | gfs2_write_calc_reserv(ip, write_len, &data_blocks, &ind_blocks); |
375 | 365 | ||
@@ -386,7 +376,7 @@ static int gfs2_prepare_write(struct file *file, struct page *page, | |||
386 | if (error) | 376 | if (error) |
387 | goto out_alloc_put; | 377 | goto out_alloc_put; |
388 | 378 | ||
389 | error = gfs2_quota_check(ip, ip->i_di.di_uid, ip->i_di.di_gid); | 379 | error = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid); |
390 | if (error) | 380 | if (error) |
391 | goto out_qunlock; | 381 | goto out_qunlock; |
392 | 382 | ||
@@ -482,8 +472,10 @@ static int gfs2_commit_write(struct file *file, struct page *page, | |||
482 | 472 | ||
483 | SetPageUptodate(page); | 473 | SetPageUptodate(page); |
484 | 474 | ||
485 | if (inode->i_size < file_size) | 475 | if (inode->i_size < file_size) { |
486 | i_size_write(inode, file_size); | 476 | i_size_write(inode, file_size); |
477 | mark_inode_dirty(inode); | ||
478 | } | ||
487 | } else { | 479 | } else { |
488 | if (sdp->sd_args.ar_data == GFS2_DATA_ORDERED || | 480 | if (sdp->sd_args.ar_data == GFS2_DATA_ORDERED || |
489 | gfs2_is_jdata(ip)) | 481 | gfs2_is_jdata(ip)) |
@@ -498,11 +490,6 @@ static int gfs2_commit_write(struct file *file, struct page *page, | |||
498 | di->di_size = cpu_to_be64(inode->i_size); | 490 | di->di_size = cpu_to_be64(inode->i_size); |
499 | } | 491 | } |
500 | 492 | ||
501 | di->di_mode = cpu_to_be32(inode->i_mode); | ||
502 | di->di_atime = cpu_to_be64(inode->i_atime.tv_sec); | ||
503 | di->di_mtime = cpu_to_be64(inode->i_mtime.tv_sec); | ||
504 | di->di_ctime = cpu_to_be64(inode->i_ctime.tv_sec); | ||
505 | |||
506 | brelse(dibh); | 493 | brelse(dibh); |
507 | gfs2_trans_end(sdp); | 494 | gfs2_trans_end(sdp); |
508 | if (al->al_requested) { | 495 | if (al->al_requested) { |
@@ -624,7 +611,7 @@ static ssize_t gfs2_direct_IO(int rw, struct kiocb *iocb, | |||
624 | * on this path. All we need change is atime. | 611 | * on this path. All we need change is atime. |
625 | */ | 612 | */ |
626 | gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &gh); | 613 | gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &gh); |
627 | rv = gfs2_glock_nq_m_atime(1, &gh); | 614 | rv = gfs2_glock_nq_atime(&gh); |
628 | if (rv) | 615 | if (rv) |
629 | goto out; | 616 | goto out; |
630 | 617 | ||
@@ -737,6 +724,9 @@ int gfs2_releasepage(struct page *page, gfp_t gfp_mask) | |||
737 | if (!atomic_read(&aspace->i_writecount)) | 724 | if (!atomic_read(&aspace->i_writecount)) |
738 | return 0; | 725 | return 0; |
739 | 726 | ||
727 | if (!(gfp_mask & __GFP_WAIT)) | ||
728 | return 0; | ||
729 | |||
740 | if (time_after_eq(jiffies, t)) { | 730 | if (time_after_eq(jiffies, t)) { |
741 | stuck_releasepage(bh); | 731 | stuck_releasepage(bh); |
742 | /* should we withdraw here? */ | 732 | /* should we withdraw here? */ |