aboutsummaryrefslogtreecommitdiffstats
path: root/fs/direct-io.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2010-06-04 05:29:53 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2010-08-09 16:47:29 -0400
commiteafdc7d190a944c755a9fe68573c193e6e0217e7 (patch)
tree915c3cc8004706fabf88eae1ab123a3fa0147516 /fs/direct-io.c
parent256249584bda1a9357e2d29987a37f5b2df035f6 (diff)
sort out blockdev_direct_IO variants
Move the call to vmtruncate to get rid of accessive blocks to the callers in prepearation of the new truncate calling sequence. This was only done for DIO_LOCKING filesystems, so the __blockdev_direct_IO_newtrunc variant was not needed anyway. Get rid of blockdev_direct_IO_no_locking and its _newtrunc variant while at it as just opencoding the two additional paramters is shorted than the name suffix. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/direct-io.c')
-rw-r--r--fs/direct-io.c74
1 files changed, 20 insertions, 54 deletions
diff --git a/fs/direct-io.c b/fs/direct-io.c
index a10cb91cadea..51f270b479b6 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -1136,8 +1136,27 @@ direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode,
1136 return ret; 1136 return ret;
1137} 1137}
1138 1138
1139/*
1140 * This is a library function for use by filesystem drivers.
1141 *
1142 * The locking rules are governed by the flags parameter:
1143 * - if the flags value contains DIO_LOCKING we use a fancy locking
1144 * scheme for dumb filesystems.
1145 * For writes this function is called under i_mutex and returns with
1146 * i_mutex held, for reads, i_mutex is not held on entry, but it is
1147 * taken and dropped again before returning.
1148 * For reads and writes i_alloc_sem is taken in shared mode and released
1149 * on I/O completion (which may happen asynchronously after returning to
1150 * the caller).
1151 *
1152 * - if the flags value does NOT contain DIO_LOCKING we don't use any
1153 * internal locking but rather rely on the filesystem to synchronize
1154 * direct I/O reads/writes versus each other and truncate.
1155 * For reads and writes both i_mutex and i_alloc_sem are not held on
1156 * entry and are never taken.
1157 */
1139ssize_t 1158ssize_t
1140__blockdev_direct_IO_newtrunc(int rw, struct kiocb *iocb, struct inode *inode, 1159__blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
1141 struct block_device *bdev, const struct iovec *iov, loff_t offset, 1160 struct block_device *bdev, const struct iovec *iov, loff_t offset,
1142 unsigned long nr_segs, get_block_t get_block, dio_iodone_t end_io, 1161 unsigned long nr_segs, get_block_t get_block, dio_iodone_t end_io,
1143 dio_submit_t submit_io, int flags) 1162 dio_submit_t submit_io, int flags)
@@ -1233,57 +1252,4 @@ __blockdev_direct_IO_newtrunc(int rw, struct kiocb *iocb, struct inode *inode,
1233out: 1252out:
1234 return retval; 1253 return retval;
1235} 1254}
1236EXPORT_SYMBOL(__blockdev_direct_IO_newtrunc);
1237
1238/*
1239 * This is a library function for use by filesystem drivers.
1240 *
1241 * The locking rules are governed by the flags parameter:
1242 * - if the flags value contains DIO_LOCKING we use a fancy locking
1243 * scheme for dumb filesystems.
1244 * For writes this function is called under i_mutex and returns with
1245 * i_mutex held, for reads, i_mutex is not held on entry, but it is
1246 * taken and dropped again before returning.
1247 * For reads and writes i_alloc_sem is taken in shared mode and released
1248 * on I/O completion (which may happen asynchronously after returning to
1249 * the caller).
1250 *
1251 * - if the flags value does NOT contain DIO_LOCKING we don't use any
1252 * internal locking but rather rely on the filesystem to synchronize
1253 * direct I/O reads/writes versus each other and truncate.
1254 * For reads and writes both i_mutex and i_alloc_sem are not held on
1255 * entry and are never taken.
1256 */
1257ssize_t
1258__blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
1259 struct block_device *bdev, const struct iovec *iov, loff_t offset,
1260 unsigned long nr_segs, get_block_t get_block, dio_iodone_t end_io,
1261 dio_submit_t submit_io, int flags)
1262{
1263 ssize_t retval;
1264
1265 retval = __blockdev_direct_IO_newtrunc(rw, iocb, inode, bdev, iov,
1266 offset, nr_segs, get_block, end_io, submit_io, flags);
1267 /*
1268 * In case of error extending write may have instantiated a few
1269 * blocks outside i_size. Trim these off again for DIO_LOCKING.
1270 * NOTE: DIO_NO_LOCK/DIO_OWN_LOCK callers have to handle this in
1271 * their own manner. This is a further example of where the old
1272 * truncate sequence is inadequate.
1273 *
1274 * NOTE: filesystems with their own locking have to handle this
1275 * on their own.
1276 */
1277 if (flags & DIO_LOCKING) {
1278 if (unlikely((rw & WRITE) && retval < 0)) {
1279 loff_t isize = i_size_read(inode);
1280 loff_t end = offset + iov_length(iov, nr_segs);
1281
1282 if (end > isize)
1283 vmtruncate(inode, isize);
1284 }
1285 }
1286
1287 return retval;
1288}
1289EXPORT_SYMBOL(__blockdev_direct_IO); 1255EXPORT_SYMBOL(__blockdev_direct_IO);