Skip to content

Commit 03a3617

Browse files
joannekoongMiklos Szeredi
authored andcommitted
fuse: use boolean bit-fields in struct fuse_copy_state
Refactor struct fuse_copy_state to use boolean bit-fields to improve clarity/readability and be consistent with other fuse structs that use bit-fields for boolean state (eg fuse_fs_context, fuse_args). No functional changes. Signed-off-by: Joanne Koong <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]>
1 parent a5c4983 commit 03a3617

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

fs/fuse/dev.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ static int unlock_request(struct fuse_req *req)
816816
return err;
817817
}
818818

819-
void fuse_copy_init(struct fuse_copy_state *cs, int write,
819+
void fuse_copy_init(struct fuse_copy_state *cs, bool write,
820820
struct iov_iter *iter)
821821
{
822822
memset(cs, 0, sizeof(*cs));
@@ -1538,7 +1538,7 @@ static ssize_t fuse_dev_read(struct kiocb *iocb, struct iov_iter *to)
15381538
if (!user_backed_iter(to))
15391539
return -EINVAL;
15401540

1541-
fuse_copy_init(&cs, 1, to);
1541+
fuse_copy_init(&cs, true, to);
15421542

15431543
return fuse_dev_do_read(fud, file, &cs, iov_iter_count(to));
15441544
}
@@ -1561,7 +1561,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
15611561
if (!bufs)
15621562
return -ENOMEM;
15631563

1564-
fuse_copy_init(&cs, 1, NULL);
1564+
fuse_copy_init(&cs, true, NULL);
15651565
cs.pipebufs = bufs;
15661566
cs.pipe = pipe;
15671567
ret = fuse_dev_do_read(fud, in, &cs, len);
@@ -2038,7 +2038,7 @@ static int fuse_notify(struct fuse_conn *fc, enum fuse_notify_code code,
20382038
unsigned int size, struct fuse_copy_state *cs)
20392039
{
20402040
/* Don't try to move pages (yet) */
2041-
cs->move_pages = 0;
2041+
cs->move_pages = false;
20422042

20432043
switch (code) {
20442044
case FUSE_NOTIFY_POLL:
@@ -2189,7 +2189,7 @@ static ssize_t fuse_dev_do_write(struct fuse_dev *fud,
21892189
spin_unlock(&fpq->lock);
21902190
cs->req = req;
21912191
if (!req->args->page_replace)
2192-
cs->move_pages = 0;
2192+
cs->move_pages = false;
21932193

21942194
if (oh.error)
21952195
err = nbytes != sizeof(oh) ? -EINVAL : 0;
@@ -2227,7 +2227,7 @@ static ssize_t fuse_dev_write(struct kiocb *iocb, struct iov_iter *from)
22272227
if (!user_backed_iter(from))
22282228
return -EINVAL;
22292229

2230-
fuse_copy_init(&cs, 0, from);
2230+
fuse_copy_init(&cs, false, from);
22312231

22322232
return fuse_dev_do_write(fud, &cs, iov_iter_count(from));
22332233
}
@@ -2301,13 +2301,13 @@ static ssize_t fuse_dev_splice_write(struct pipe_inode_info *pipe,
23012301
}
23022302
pipe_unlock(pipe);
23032303

2304-
fuse_copy_init(&cs, 0, NULL);
2304+
fuse_copy_init(&cs, false, NULL);
23052305
cs.pipebufs = bufs;
23062306
cs.nr_segs = nbuf;
23072307
cs.pipe = pipe;
23082308

23092309
if (flags & SPLICE_F_MOVE)
2310-
cs.move_pages = 1;
2310+
cs.move_pages = true;
23112311

23122312
ret = fuse_dev_do_write(fud, &cs, len);
23132313

fs/fuse/dev_uring.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,8 @@ static int fuse_uring_copy_from_ring(struct fuse_ring *ring,
577577
if (err)
578578
return err;
579579

580-
fuse_copy_init(&cs, 0, &iter);
581-
cs.is_uring = 1;
580+
fuse_copy_init(&cs, false, &iter);
581+
cs.is_uring = true;
582582
cs.req = req;
583583

584584
return fuse_copy_out_args(&cs, args, ring_in_out.payload_sz);
@@ -607,8 +607,8 @@ static int fuse_uring_args_to_ring(struct fuse_ring *ring, struct fuse_req *req,
607607
return err;
608608
}
609609

610-
fuse_copy_init(&cs, 1, &iter);
611-
cs.is_uring = 1;
610+
fuse_copy_init(&cs, true, &iter);
611+
cs.is_uring = true;
612612
cs.req = req;
613613

614614
if (num_args > 0) {

fs/fuse/fuse_dev_i.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ struct fuse_copy_state {
2929
struct page *pg;
3030
unsigned int len;
3131
unsigned int offset;
32-
unsigned int write:1;
33-
unsigned int move_pages:1;
34-
unsigned int is_uring:1;
32+
bool write:1;
33+
bool move_pages:1;
34+
bool is_uring:1;
3535
struct {
3636
unsigned int copied_sz; /* copied size into the user buffer */
3737
} ring;
@@ -51,7 +51,7 @@ struct fuse_req *fuse_request_find(struct fuse_pqueue *fpq, u64 unique);
5151

5252
void fuse_dev_end_requests(struct list_head *head);
5353

54-
void fuse_copy_init(struct fuse_copy_state *cs, int write,
54+
void fuse_copy_init(struct fuse_copy_state *cs, bool write,
5555
struct iov_iter *iter);
5656
int fuse_copy_args(struct fuse_copy_state *cs, unsigned int numargs,
5757
unsigned int argpages, struct fuse_arg *args,

0 commit comments

Comments
 (0)