iov_iter: Derive user-backedness from the iterator type
authorDavid Howells <dhowells@redhat.com>
Mon, 25 Sep 2023 12:03:03 +0000 (13:03 +0100)
committerChristian Brauner <brauner@kernel.org>
Mon, 25 Sep 2023 12:30:28 +0000 (14:30 +0200)
Use the iterator type to determine whether an iterator is user-backed or
not rather than using a special flag for it.  Now that ITER_UBUF and
ITER_IOVEC are 0 and 1, they can be checked with a single comparison.

Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://lore.kernel.org/r/20230925120309.1731676-7-dhowells@redhat.com
cc: Alexander Viro <viro@zeniv.linux.org.uk>
cc: Jens Axboe <axboe@kernel.dk>
cc: Christoph Hellwig <hch@lst.de>
cc: Christian Brauner <christian@brauner.io>
cc: Matthew Wilcox <willy@infradead.org>
cc: Linus Torvalds <torvalds@linux-foundation.org>
cc: David Laight <David.Laight@ACULAB.COM>
cc: linux-block@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
cc: linux-mm@kvack.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
include/linux/uio.h
lib/iov_iter.c

index bef8e56aa45c2f202d9f86562a71cefcb44a7a07..65d9143f83c8f323978d4f8172aea8f7d1f07f8a 100644 (file)
@@ -43,7 +43,6 @@ struct iov_iter {
        bool copy_mc;
        bool nofault;
        bool data_source;
-       bool user_backed;
        size_t iov_offset;
        /*
         * Hack alert: overlay ubuf_iovec with iovec + count, so
@@ -140,7 +139,7 @@ static inline unsigned char iov_iter_rw(const struct iov_iter *i)
 
 static inline bool user_backed_iter(const struct iov_iter *i)
 {
-       return i->user_backed;
+       return iter_is_ubuf(i) || iter_is_iovec(i);
 }
 
 /*
@@ -380,7 +379,6 @@ static inline void iov_iter_ubuf(struct iov_iter *i, unsigned int direction,
        *i = (struct iov_iter) {
                .iter_type = ITER_UBUF,
                .copy_mc = false,
-               .user_backed = true,
                .data_source = direction,
                .ubuf = buf,
                .count = count,
index 27234a820eeb390f99e26f55002e51b2f95864e7..227c9f536b94aade0bf37a8b25210febb63e391a 100644 (file)
@@ -290,7 +290,6 @@ void iov_iter_init(struct iov_iter *i, unsigned int direction,
                .iter_type = ITER_IOVEC,
                .copy_mc = false,
                .nofault = false,
-               .user_backed = true,
                .data_source = direction,
                .__iov = iov,
                .nr_segs = nr_segs,