Commit 4442f2e0 authored by Steven Whitehouse's avatar Steven Whitehouse

GFS2: O_(D)SYNC support for fallocate

Add sync of metadata after fallocate for O_SYNC files to ensure that we
meet expectations for everything being on disk in this case.
Unfortunately, the offset and len parameters are modified during the
course of the fallocate function, so I've had to add a couple of new
variables to call generic_write_sync() at the end.

I know that potentially this will sync data as well within the range,
but I think that is a fairly harmless side-effect overall, since we
would not normally expect there to be any dirty data within the range in
question.
Signed-off-by: default avatarSteven Whitehouse <swhiteho@redhat.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Benjamin Marzinski <bmarzins@redhat.com>
parent b9f417f3
...@@ -752,6 +752,8 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset, ...@@ -752,6 +752,8 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
loff_t bytes, max_bytes; loff_t bytes, max_bytes;
struct gfs2_alloc *al; struct gfs2_alloc *al;
int error; int error;
const loff_t pos = offset;
const loff_t count = len;
loff_t bsize_mask = ~((loff_t)sdp->sd_sb.sb_bsize - 1); loff_t bsize_mask = ~((loff_t)sdp->sd_sb.sb_bsize - 1);
loff_t next = (offset + len - 1) >> sdp->sd_sb.sb_bsize_shift; loff_t next = (offset + len - 1) >> sdp->sd_sb.sb_bsize_shift;
loff_t max_chunk_size = UINT_MAX & bsize_mask; loff_t max_chunk_size = UINT_MAX & bsize_mask;
...@@ -834,6 +836,9 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset, ...@@ -834,6 +836,9 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
gfs2_quota_unlock(ip); gfs2_quota_unlock(ip);
gfs2_alloc_put(ip); gfs2_alloc_put(ip);
} }
if (error == 0)
error = generic_write_sync(file, pos, count);
goto out_unlock; goto out_unlock;
out_trans_fail: out_trans_fail:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment