aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2009-08-20 11:43:41 -0400
committerJan Kara <jack@suse.cz>2009-09-14 11:08:15 -0400
commiteef99380679e20e7edc096aa4d8a98b875404d79 (patch)
tree358a39148e8513eed9ba6aaff13f6bf660a2ce1e
parent918941a3f3d46c2a69971b4718aaf13b1be2f1a7 (diff)
vfs: Rename generic_file_aio_write_nolock
generic_file_aio_write_nolock() is now used only by block devices and raw character device. Filesystems should use __generic_file_aio_write() in case generic_file_aio_write() doesn't suit them. So rename the function to blkdev_aio_write() and move it to fs/blockdev.c. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r--drivers/char/raw.c2
-rw-r--r--fs/block_dev.c29
-rw-r--r--include/linux/fs.h6
-rw-r--r--mm/filemap.c39
4 files changed, 33 insertions, 43 deletions
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 05f9d18b9361..40268db02e22 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -246,7 +246,7 @@ static const struct file_operations raw_fops = {
246 .read = do_sync_read, 246 .read = do_sync_read,
247 .aio_read = generic_file_aio_read, 247 .aio_read = generic_file_aio_read,
248 .write = do_sync_write, 248 .write = do_sync_write,
249 .aio_write = generic_file_aio_write_nolock, 249 .aio_write = blkdev_aio_write,
250 .open = raw_open, 250 .open = raw_open,
251 .release= raw_release, 251 .release= raw_release,
252 .ioctl = raw_ioctl, 252 .ioctl = raw_ioctl,
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 94dfda24c06e..3581a4e53942 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1405,6 +1405,33 @@ static long block_ioctl(struct file *file, unsigned cmd, unsigned long arg)
1405} 1405}
1406 1406
1407/* 1407/*
1408 * Write data to the block device. Only intended for the block device itself
1409 * and the raw driver which basically is a fake block device.
1410 *
1411 * Does not take i_mutex for the write and thus is not for general purpose
1412 * use.
1413 */
1414ssize_t blkdev_aio_write(struct kiocb *iocb, const struct iovec *iov,
1415 unsigned long nr_segs, loff_t pos)
1416{
1417 struct file *file = iocb->ki_filp;
1418 ssize_t ret;
1419
1420 BUG_ON(iocb->ki_pos != pos);
1421
1422 ret = __generic_file_aio_write(iocb, iov, nr_segs, &iocb->ki_pos);
1423 if (ret > 0 || ret == -EIOCBQUEUED) {
1424 ssize_t err;
1425
1426 err = generic_write_sync(file, pos, ret);
1427 if (err < 0 && ret > 0)
1428 ret = err;
1429 }
1430 return ret;
1431}
1432EXPORT_SYMBOL_GPL(blkdev_aio_write);
1433
1434/*
1408 * Try to release a page associated with block device when the system 1435 * Try to release a page associated with block device when the system
1409 * is under memory pressure. 1436 * is under memory pressure.
1410 */ 1437 */
@@ -1436,7 +1463,7 @@ const struct file_operations def_blk_fops = {
1436 .read = do_sync_read, 1463 .read = do_sync_read,
1437 .write = do_sync_write, 1464 .write = do_sync_write,
1438 .aio_read = generic_file_aio_read, 1465 .aio_read = generic_file_aio_read,
1439 .aio_write = generic_file_aio_write_nolock, 1466 .aio_write = blkdev_aio_write,
1440 .mmap = generic_file_mmap, 1467 .mmap = generic_file_mmap,
1441 .fsync = block_fsync, 1468 .fsync = block_fsync,
1442 .unlocked_ioctl = block_ioctl, 1469 .unlocked_ioctl = block_ioctl,
diff --git a/include/linux/fs.h b/include/linux/fs.h
index ea099d3a18d9..6c1be3a4edea 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2207,8 +2207,6 @@ extern ssize_t generic_file_aio_read(struct kiocb *, const struct iovec *, unsig
2207extern ssize_t __generic_file_aio_write(struct kiocb *, const struct iovec *, unsigned long, 2207extern ssize_t __generic_file_aio_write(struct kiocb *, const struct iovec *, unsigned long,
2208 loff_t *); 2208 loff_t *);
2209extern ssize_t generic_file_aio_write(struct kiocb *, const struct iovec *, unsigned long, loff_t); 2209extern ssize_t generic_file_aio_write(struct kiocb *, const struct iovec *, unsigned long, loff_t);
2210extern ssize_t generic_file_aio_write_nolock(struct kiocb *, const struct iovec *,
2211 unsigned long, loff_t);
2212extern ssize_t generic_file_direct_write(struct kiocb *, const struct iovec *, 2210extern ssize_t generic_file_direct_write(struct kiocb *, const struct iovec *,
2213 unsigned long *, loff_t, loff_t *, size_t, size_t); 2211 unsigned long *, loff_t, loff_t *, size_t, size_t);
2214extern ssize_t generic_file_buffered_write(struct kiocb *, const struct iovec *, 2212extern ssize_t generic_file_buffered_write(struct kiocb *, const struct iovec *,
@@ -2218,6 +2216,10 @@ extern ssize_t do_sync_write(struct file *filp, const char __user *buf, size_t l
2218extern int generic_segment_checks(const struct iovec *iov, 2216extern int generic_segment_checks(const struct iovec *iov,
2219 unsigned long *nr_segs, size_t *count, int access_flags); 2217 unsigned long *nr_segs, size_t *count, int access_flags);
2220 2218
2219/* fs/block_dev.c */
2220extern ssize_t blkdev_aio_write(struct kiocb *iocb, const struct iovec *iov,
2221 unsigned long nr_segs, loff_t pos);
2222
2221/* fs/splice.c */ 2223/* fs/splice.c */
2222extern ssize_t generic_file_splice_read(struct file *, loff_t *, 2224extern ssize_t generic_file_splice_read(struct file *, loff_t *,
2223 struct pipe_inode_info *, size_t, unsigned int); 2225 struct pipe_inode_info *, size_t, unsigned int);
diff --git a/mm/filemap.c b/mm/filemap.c
index f863e1d7e227..3587554f45ef 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2462,45 +2462,6 @@ out:
2462} 2462}
2463EXPORT_SYMBOL(__generic_file_aio_write); 2463EXPORT_SYMBOL(__generic_file_aio_write);
2464 2464
2465
2466/**
2467 * generic_file_aio_write_nolock - write data, usually to a device
2468 * @iocb: IO state structure
2469 * @iov: vector with data to write
2470 * @nr_segs: number of segments in the vector
2471 * @pos: position in file where to write
2472 *
2473 * This is a wrapper around __generic_file_aio_write() which takes care of
2474 * syncing the file in case of O_SYNC file. It does not take i_mutex for the
2475 * write itself but may do so during syncing. It is meant for users like block
2476 * devices which do not need i_mutex during write. If your filesystem needs to
2477 * do a write but already holds i_mutex, use __generic_file_aio_write()
2478 * directly and then sync the file like generic_file_aio_write().
2479 */
2480ssize_t generic_file_aio_write_nolock(struct kiocb *iocb,
2481 const struct iovec *iov, unsigned long nr_segs, loff_t pos)
2482{
2483 struct file *file = iocb->ki_filp;
2484 struct address_space *mapping = file->f_mapping;
2485 struct inode *inode = mapping->host;
2486 ssize_t ret;
2487
2488 BUG_ON(iocb->ki_pos != pos);
2489
2490 ret = __generic_file_aio_write(iocb, iov, nr_segs, &iocb->ki_pos);
2491
2492 if ((ret > 0 || ret == -EIOCBQUEUED) &&
2493 ((file->f_flags & O_SYNC) || IS_SYNC(inode))) {
2494 ssize_t err;
2495
2496 err = sync_page_range_nolock(inode, mapping, pos, ret);
2497 if (err < 0 && ret > 0)
2498 ret = err;
2499 }
2500 return ret;
2501}
2502EXPORT_SYMBOL(generic_file_aio_write_nolock);
2503
2504/** 2465/**
2505 * generic_file_aio_write - write data to a file 2466 * generic_file_aio_write - write data to a file
2506 * @iocb: IO state structure 2467 * @iocb: IO state structure