diff options
Diffstat (limited to 'fs/gfs2/file.c')
-rw-r--r-- | fs/gfs2/file.c | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index e48310885c48..a9f5cbe45cd9 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c | |||
@@ -545,18 +545,10 @@ static int gfs2_close(struct inode *inode, struct file *file) | |||
545 | /** | 545 | /** |
546 | * gfs2_fsync - sync the dirty data for a file (across the cluster) | 546 | * gfs2_fsync - sync the dirty data for a file (across the cluster) |
547 | * @file: the file that points to the dentry (we ignore this) | 547 | * @file: the file that points to the dentry (we ignore this) |
548 | * @dentry: the dentry that points to the inode to sync | 548 | * @datasync: set if we can ignore timestamp changes |
549 | * | 549 | * |
550 | * The VFS will flush "normal" data for us. We only need to worry | 550 | * The VFS will flush data for us. We only need to worry |
551 | * about metadata here. For journaled data, we just do a log flush | 551 | * about metadata here. |
552 | * as we can't avoid it. Otherwise we can just bale out if datasync | ||
553 | * is set. For stuffed inodes we must flush the log in order to | ||
554 | * ensure that all data is on disk. | ||
555 | * | ||
556 | * The call to write_inode_now() is there to write back metadata and | ||
557 | * the inode itself. It does also try and write the data, but thats | ||
558 | * (hopefully) a no-op due to the VFS having already called filemap_fdatawrite() | ||
559 | * for us. | ||
560 | * | 552 | * |
561 | * Returns: errno | 553 | * Returns: errno |
562 | */ | 554 | */ |
@@ -565,22 +557,20 @@ static int gfs2_fsync(struct file *file, int datasync) | |||
565 | { | 557 | { |
566 | struct inode *inode = file->f_mapping->host; | 558 | struct inode *inode = file->f_mapping->host; |
567 | int sync_state = inode->i_state & (I_DIRTY_SYNC|I_DIRTY_DATASYNC); | 559 | int sync_state = inode->i_state & (I_DIRTY_SYNC|I_DIRTY_DATASYNC); |
568 | int ret = 0; | 560 | struct gfs2_inode *ip = GFS2_I(inode); |
569 | 561 | int ret; | |
570 | if (gfs2_is_jdata(GFS2_I(inode))) { | ||
571 | gfs2_log_flush(GFS2_SB(inode), GFS2_I(inode)->i_gl); | ||
572 | return 0; | ||
573 | } | ||
574 | 562 | ||
575 | if (sync_state != 0) { | 563 | if (datasync) |
576 | if (!datasync) | 564 | sync_state &= ~I_DIRTY_SYNC; |
577 | ret = write_inode_now(inode, 0); | ||
578 | 565 | ||
579 | if (gfs2_is_stuffed(GFS2_I(inode))) | 566 | if (sync_state) { |
580 | gfs2_log_flush(GFS2_SB(inode), GFS2_I(inode)->i_gl); | 567 | ret = sync_inode_metadata(inode, 1); |
568 | if (ret) | ||
569 | return ret; | ||
570 | gfs2_ail_flush(ip->i_gl); | ||
581 | } | 571 | } |
582 | 572 | ||
583 | return ret; | 573 | return 0; |
584 | } | 574 | } |
585 | 575 | ||
586 | /** | 576 | /** |
@@ -826,6 +816,7 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset, | |||
826 | loff_t bytes, max_bytes; | 816 | loff_t bytes, max_bytes; |
827 | struct gfs2_alloc *al; | 817 | struct gfs2_alloc *al; |
828 | int error; | 818 | int error; |
819 | loff_t bsize_mask = ~((loff_t)sdp->sd_sb.sb_bsize - 1); | ||
829 | loff_t next = (offset + len - 1) >> sdp->sd_sb.sb_bsize_shift; | 820 | loff_t next = (offset + len - 1) >> sdp->sd_sb.sb_bsize_shift; |
830 | next = (next + 1) << sdp->sd_sb.sb_bsize_shift; | 821 | next = (next + 1) << sdp->sd_sb.sb_bsize_shift; |
831 | 822 | ||
@@ -833,13 +824,15 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset, | |||
833 | if (mode & ~FALLOC_FL_KEEP_SIZE) | 824 | if (mode & ~FALLOC_FL_KEEP_SIZE) |
834 | return -EOPNOTSUPP; | 825 | return -EOPNOTSUPP; |
835 | 826 | ||
836 | offset = (offset >> sdp->sd_sb.sb_bsize_shift) << | 827 | offset &= bsize_mask; |
837 | sdp->sd_sb.sb_bsize_shift; | ||
838 | 828 | ||
839 | len = next - offset; | 829 | len = next - offset; |
840 | bytes = sdp->sd_max_rg_data * sdp->sd_sb.sb_bsize / 2; | 830 | bytes = sdp->sd_max_rg_data * sdp->sd_sb.sb_bsize / 2; |
841 | if (!bytes) | 831 | if (!bytes) |
842 | bytes = UINT_MAX; | 832 | bytes = UINT_MAX; |
833 | bytes &= bsize_mask; | ||
834 | if (bytes == 0) | ||
835 | bytes = sdp->sd_sb.sb_bsize; | ||
843 | 836 | ||
844 | gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &ip->i_gh); | 837 | gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &ip->i_gh); |
845 | error = gfs2_glock_nq(&ip->i_gh); | 838 | error = gfs2_glock_nq(&ip->i_gh); |
@@ -870,6 +863,9 @@ retry: | |||
870 | if (error) { | 863 | if (error) { |
871 | if (error == -ENOSPC && bytes > sdp->sd_sb.sb_bsize) { | 864 | if (error == -ENOSPC && bytes > sdp->sd_sb.sb_bsize) { |
872 | bytes >>= 1; | 865 | bytes >>= 1; |
866 | bytes &= bsize_mask; | ||
867 | if (bytes == 0) | ||
868 | bytes = sdp->sd_sb.sb_bsize; | ||
873 | goto retry; | 869 | goto retry; |
874 | } | 870 | } |
875 | goto out_qunlock; | 871 | goto out_qunlock; |