lift sb_start_write() out of ->write()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 747bb2a..cd1e174 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -230,9 +230,11 @@
ssize_t bw;
mm_segment_t old_fs = get_fs();
+ file_start_write(file);
set_fs(get_ds());
bw = file->f_op->write(file, buf, len, &pos);
set_fs(old_fs);
+ file_end_write(file);
if (likely(bw == len))
return 0;
printk(KERN_ERR "loop: Write error at byte offset %llu, length %i.\n",
diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
index 4809922..317f9ee 100644
--- a/fs/cachefiles/rdwr.c
+++ b/fs/cachefiles/rdwr.c
@@ -962,12 +962,14 @@
}
data = kmap(page);
+ file_start_write(file);
old_fs = get_fs();
set_fs(KERNEL_DS);
ret = file->f_op->write(
file, (const void __user *) data, len, &pos);
set_fs(old_fs);
kunmap(page);
+ file_end_write(file);
if (ret != len)
ret = -EIO;
}
diff --git a/fs/coda/file.c b/fs/coda/file.c
index fa4c100..380b798 100644
--- a/fs/coda/file.c
+++ b/fs/coda/file.c
@@ -79,6 +79,7 @@
return -EINVAL;
host_inode = file_inode(host_file);
+ file_start_write(host_file);
mutex_lock(&coda_inode->i_mutex);
ret = host_file->f_op->write(host_file, buf, count, ppos);
@@ -87,6 +88,7 @@
coda_inode->i_blocks = (coda_inode->i_size + 511) >> 9;
coda_inode->i_mtime = coda_inode->i_ctime = CURRENT_TIME_SEC;
mutex_unlock(&coda_inode->i_mutex);
+ file_end_write(host_file);
return ret;
}
diff --git a/fs/coredump.c b/fs/coredump.c
index c647965..288e5c9 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -629,9 +629,11 @@
goto close_fail;
if (displaced)
put_files_struct(displaced);
+ file_start_write(cprm.file);
retval = binfmt->core_dump(&cprm);
if (retval)
current->signal->group_exit_code |= 0x80;
+ file_end_write(cprm.file);
if (ispipe && core_pipe_limit)
wait_for_dump_helpers(cprm.file);
diff --git a/fs/read_write.c b/fs/read_write.c
index e6dd1c2..a1f4d44 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -398,7 +398,6 @@
struct kiocb kiocb;
ssize_t ret;
- file_start_write(filp);
init_sync_kiocb(&kiocb, filp);
kiocb.ki_pos = *ppos;
kiocb.ki_left = len;
@@ -414,7 +413,6 @@
if (-EIOCBQUEUED == ret)
ret = wait_on_sync_kiocb(&kiocb);
*ppos = kiocb.ki_pos;
- file_end_write(filp);
return ret;
}
@@ -458,6 +456,7 @@
ret = rw_verify_area(WRITE, file, pos, count);
if (ret >= 0) {
count = ret;
+ file_start_write(file);
if (file->f_op->write)
ret = file->f_op->write(file, buf, count, pos);
else
@@ -467,6 +466,7 @@
add_wchar(current, ret);
}
inc_syscw(current);
+ file_end_write(file);
}
return ret;
@@ -758,16 +758,18 @@
} else {
fn = (io_fn_t)file->f_op->write;
fnv = file->f_op->aio_write;
+ file_start_write(file);
}
- if (fnv) {
- file_start_write(file);
+ if (fnv)
ret = do_sync_readv_writev(file, iov, nr_segs, tot_len,
pos, fnv);
- file_end_write(file);
- } else
+ else
ret = do_loop_readv_writev(file, iov, nr_segs, pos, fn);
+ if (type != READ)
+ file_end_write(file);
+
out:
if (iov != iovstack)
kfree(iov);
@@ -936,16 +938,18 @@
} else {
fn = (io_fn_t)file->f_op->write;
fnv = file->f_op->aio_write;
+ file_start_write(file);
}
- if (fnv) {
- file_start_write(file);
+ if (fnv)
ret = do_sync_readv_writev(file, iov, nr_segs, tot_len,
pos, fnv);
- file_end_write(file);
- } else
+ else
ret = do_loop_readv_writev(file, iov, nr_segs, pos, fn);
+ if (type != READ)
+ file_end_write(file);
+
out:
if (iov != iovstack)
kfree(iov);
diff --git a/fs/splice.c b/fs/splice.c
index 29e394e..e78a749 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -1052,7 +1052,9 @@
loff_t tmp = sd->pos;
data = buf->ops->map(pipe, buf, 0);
+ file_start_write(sd->u.file);
ret = __kernel_write(sd->u.file, data + buf->offset, sd->len, &tmp);
+ file_end_write(sd->u.file);
buf->ops->unmap(pipe, buf, data);
return ret;
diff --git a/kernel/acct.c b/kernel/acct.c
index b9bd7f0..85389fe 100644
--- a/kernel/acct.c
+++ b/kernel/acct.c
@@ -543,6 +543,7 @@
* Kernel segment override to datasegment and write it
* to the accounting file.
*/
+ file_start_write(file);
fs = get_fs();
set_fs(KERNEL_DS);
/*
@@ -554,6 +555,7 @@
sizeof(acct_t), &file->f_pos);
current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
set_fs(fs);
+ file_end_write(file);
out:
revert_creds(orig_cred);
}
diff --git a/mm/filemap_xip.c b/mm/filemap_xip.c
index a912da6..28fe26b 100644
--- a/mm/filemap_xip.c
+++ b/mm/filemap_xip.c
@@ -404,8 +404,6 @@
loff_t pos;
ssize_t ret;
- sb_start_write(inode->i_sb);
-
mutex_lock(&inode->i_mutex);
if (!access_ok(VERIFY_READ, buf, len)) {
@@ -439,7 +437,6 @@
current->backing_dev_info = NULL;
out_up:
mutex_unlock(&inode->i_mutex);
- sb_end_write(inode->i_sb);
return ret;
}
EXPORT_SYMBOL_GPL(xip_file_write);