Skip to content

Commit 805c6d3

Browse files
committed
Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs fixes from Al Viro: "No common topic, just assorted fixes" * 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: fuse: fix the ->direct_IO() treatment of iov_iter fs: fix cast in fsparam_u32hex() macro vboxsf: Fix the check for the old binary mount-arguments struct
2 parents d301713 + 933a375 commit 805c6d3

3 files changed

Lines changed: 14 additions & 15 deletions

File tree

fs/fuse/file.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3091,29 +3091,20 @@ fuse_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
30913091
ssize_t ret = 0;
30923092
struct file *file = iocb->ki_filp;
30933093
struct fuse_file *ff = file->private_data;
3094-
bool async_dio = ff->fc->async_dio;
30953094
loff_t pos = 0;
30963095
struct inode *inode;
30973096
loff_t i_size;
3098-
size_t count = iov_iter_count(iter);
3097+
size_t count = iov_iter_count(iter), shortened = 0;
30993098
loff_t offset = iocb->ki_pos;
31003099
struct fuse_io_priv *io;
31013100

31023101
pos = offset;
31033102
inode = file->f_mapping->host;
31043103
i_size = i_size_read(inode);
31053104

3106-
if ((iov_iter_rw(iter) == READ) && (offset > i_size))
3105+
if ((iov_iter_rw(iter) == READ) && (offset >= i_size))
31073106
return 0;
31083107

3109-
/* optimization for short read */
3110-
if (async_dio && iov_iter_rw(iter) != WRITE && offset + count > i_size) {
3111-
if (offset >= i_size)
3112-
return 0;
3113-
iov_iter_truncate(iter, fuse_round_up(ff->fc, i_size - offset));
3114-
count = iov_iter_count(iter);
3115-
}
3116-
31173108
io = kmalloc(sizeof(struct fuse_io_priv), GFP_KERNEL);
31183109
if (!io)
31193110
return -ENOMEM;
@@ -3129,15 +3120,22 @@ fuse_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
31293120
* By default, we want to optimize all I/Os with async request
31303121
* submission to the client filesystem if supported.
31313122
*/
3132-
io->async = async_dio;
3123+
io->async = ff->fc->async_dio;
31333124
io->iocb = iocb;
31343125
io->blocking = is_sync_kiocb(iocb);
31353126

3127+
/* optimization for short read */
3128+
if (io->async && !io->write && offset + count > i_size) {
3129+
iov_iter_truncate(iter, fuse_round_up(ff->fc, i_size - offset));
3130+
shortened = count - iov_iter_count(iter);
3131+
count -= shortened;
3132+
}
3133+
31363134
/*
31373135
* We cannot asynchronously extend the size of a file.
31383136
* In such case the aio will behave exactly like sync io.
31393137
*/
3140-
if ((offset + count > i_size) && iov_iter_rw(iter) == WRITE)
3138+
if ((offset + count > i_size) && io->write)
31413139
io->blocking = true;
31423140

31433141
if (io->async && io->blocking) {
@@ -3155,6 +3153,7 @@ fuse_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
31553153
} else {
31563154
ret = __fuse_direct_read(io, iter, &pos);
31573155
}
3156+
iov_iter_reexpand(iter, iov_iter_count(iter) + shortened);
31583157

31593158
if (io->async) {
31603159
bool blocking = io->blocking;

fs/vboxsf/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ static int vboxsf_setup(void)
384384

385385
static int vboxsf_parse_monolithic(struct fs_context *fc, void *data)
386386
{
387-
char *options = data;
387+
unsigned char *options = data;
388388

389389
if (options && options[0] == VBSF_MOUNT_SIGNATURE_BYTE_0 &&
390390
options[1] == VBSF_MOUNT_SIGNATURE_BYTE_1 &&

include/linux/fs_parser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ static inline bool fs_validate_description(const char *name,
120120
#define fsparam_u32oct(NAME, OPT) \
121121
__fsparam(fs_param_is_u32, NAME, OPT, 0, (void *)8)
122122
#define fsparam_u32hex(NAME, OPT) \
123-
__fsparam(fs_param_is_u32_hex, NAME, OPT, 0, (void *16))
123+
__fsparam(fs_param_is_u32_hex, NAME, OPT, 0, (void *)16)
124124
#define fsparam_s32(NAME, OPT) __fsparam(fs_param_is_s32, NAME, OPT, 0, NULL)
125125
#define fsparam_u64(NAME, OPT) __fsparam(fs_param_is_u64, NAME, OPT, 0, NULL)
126126
#define fsparam_enum(NAME, OPT, array) __fsparam(fs_param_is_enum, NAME, OPT, 0, array)

0 commit comments

Comments
 (0)