diff options
author | Christoph Hellwig <hch@lst.de> | 2009-11-03 10:44:53 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2009-12-16 12:16:49 -0500 |
commit | 1e431f5ce78f3ae8254d725060288b78ff74f086 (patch) | |
tree | a144fd7b6120ec61958c82023b25620a18aa3d6d /include | |
parent | 1c7c474c31aea6d5cb2fb35f31d9e9e91ae466b1 (diff) |
cleanup blockdev_direct_IO locking
Currently the locking in blockdev_direct_IO is a mess, we have three different
locking types and very confusing checks for some of them. The most
complicated one is DIO_OWN_LOCKING for reads, which happens to not actually be
used.
This patch gets rid of the DIO_OWN_LOCKING - as mentioned above the read case
is unused anyway, and the write side is almost identical to DIO_NO_LOCKING.
The difference is that DIO_NO_LOCKING always sets the create argument for
the get_blocks callback to zero, but we can easily move that to the actual
get_blocks callbacks. There are four users of the DIO_NO_LOCKING mode:
gfs already ignores the create argument and thus is fine with the new
version, ocfs2 only errors out if create were ever set, and we can remove
this dead code now, the block device code only ever uses create for an
error message if we are fully beyond the device which can never happen,
and last but not least XFS will need the new behavour for writes.
Now we can replace the lock_type variable with a flags one, where no flag
means the DIO_NO_LOCKING behaviour and DIO_LOCKING is kept as the first
flag. Separate out the check for not allowing to fill holes into a separate
flag, although for now both flags always get set at the same time.
Also revamp the documentation of the locking scheme to actually make sense.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/fs.h | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h index cdc23be4edde..7c8ff12d1995 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -2263,9 +2263,11 @@ ssize_t __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode, | |||
2263 | int lock_type); | 2263 | int lock_type); |
2264 | 2264 | ||
2265 | enum { | 2265 | enum { |
2266 | DIO_LOCKING = 1, /* need locking between buffered and direct access */ | 2266 | /* need locking between buffered and direct access */ |
2267 | DIO_NO_LOCKING, /* bdev; no locking at all between buffered/direct */ | 2267 | DIO_LOCKING = 0x01, |
2268 | DIO_OWN_LOCKING, /* filesystem locks buffered and direct internally */ | 2268 | |
2269 | /* filesystem does not support filling holes */ | ||
2270 | DIO_SKIP_HOLES = 0x02, | ||
2269 | }; | 2271 | }; |
2270 | 2272 | ||
2271 | static inline ssize_t blockdev_direct_IO(int rw, struct kiocb *iocb, | 2273 | static inline ssize_t blockdev_direct_IO(int rw, struct kiocb *iocb, |
@@ -2274,7 +2276,8 @@ static inline ssize_t blockdev_direct_IO(int rw, struct kiocb *iocb, | |||
2274 | dio_iodone_t end_io) | 2276 | dio_iodone_t end_io) |
2275 | { | 2277 | { |
2276 | return __blockdev_direct_IO(rw, iocb, inode, bdev, iov, offset, | 2278 | return __blockdev_direct_IO(rw, iocb, inode, bdev, iov, offset, |
2277 | nr_segs, get_block, end_io, DIO_LOCKING); | 2279 | nr_segs, get_block, end_io, |
2280 | DIO_LOCKING | DIO_SKIP_HOLES); | ||
2278 | } | 2281 | } |
2279 | 2282 | ||
2280 | static inline ssize_t blockdev_direct_IO_no_locking(int rw, struct kiocb *iocb, | 2283 | static inline ssize_t blockdev_direct_IO_no_locking(int rw, struct kiocb *iocb, |
@@ -2283,16 +2286,7 @@ static inline ssize_t blockdev_direct_IO_no_locking(int rw, struct kiocb *iocb, | |||
2283 | dio_iodone_t end_io) | 2286 | dio_iodone_t end_io) |
2284 | { | 2287 | { |
2285 | return __blockdev_direct_IO(rw, iocb, inode, bdev, iov, offset, | 2288 | return __blockdev_direct_IO(rw, iocb, inode, bdev, iov, offset, |
2286 | nr_segs, get_block, end_io, DIO_NO_LOCKING); | 2289 | nr_segs, get_block, end_io, 0); |
2287 | } | ||
2288 | |||
2289 | static inline ssize_t blockdev_direct_IO_own_locking(int rw, struct kiocb *iocb, | ||
2290 | struct inode *inode, struct block_device *bdev, const struct iovec *iov, | ||
2291 | loff_t offset, unsigned long nr_segs, get_block_t get_block, | ||
2292 | dio_iodone_t end_io) | ||
2293 | { | ||
2294 | return __blockdev_direct_IO(rw, iocb, inode, bdev, iov, offset, | ||
2295 | nr_segs, get_block, end_io, DIO_OWN_LOCKING); | ||
2296 | } | 2290 | } |
2297 | #endif | 2291 | #endif |
2298 | 2292 | ||