Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1762874iog; Thu, 16 Jun 2022 13:19:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sZDBQ4LzOo3xmB0omkwS66sVjLtXLb/YHbtHWSgAeFaxQPn2MjXl6qyMF9tBNaqLdDuORs X-Received: by 2002:a63:397:0:b0:401:b6bc:a5ee with SMTP id 145-20020a630397000000b00401b6bca5eemr5949538pgd.437.1655410749735; Thu, 16 Jun 2022 13:19:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655410749; cv=none; d=google.com; s=arc-20160816; b=AnaW71Z7Ew3OfeJbD2g0loVU20j1+93Iyf7j4P/nb2OUIcS/3fXSU7QGeIxjlOYZgx XbP9gAbt8DCxGrFPeUu+sncH7rw6cwc+dTHEWb4ZrcmSaddCxS3Rx64EYMSr4UbJbnCG z6S+xbrDVHt9km3G2/CE4nX6auxAP1hIy3K9i5BtxgGijtup1MhpM9b40mfgn7CIxYV2 Qit29iu2P0yeMRGd46MzbYoTrd2Gs5a5oyp5RAO8b8Nfk0cNdJNU7tYt6TZqn1tc3aoH TN/Z1IG3NLn0zXYh9scXe7ECE/qSit+mP31stHyfzLT903bMor12GgJTe/eEV08qgN7r Hrvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PDIZqzl/idQMig9q8LMn5o42c1Rx/QHxWuYhKYT1tfc=; b=Kl8I8Noftt1XtHtFLzx6vmZbYRT9p3k3PrdY4PPNl0VcgUUyQ1ExEhBV9TiSUoUdn3 +4f/NncmH7A1P1WFoiEPzaNB9Wg6UP/HL4I3gawvm5nq9dvACh6XHq0u3H1g3U91yeS+ QeGdmsS6WAqI4E2LBwEs/uIVHe4/+WDmwC2aXE8wCeqomROx/uJGN3D1RRdgczBptl6p S1qZySQ5q71KZnAJy9VMiAFsMuzFK8dIAPGw1RddZBsCpRXlFz8ZNMZhArAThz6FAwf5 YwTn7hr2CVtCBrNoP4pQz8iK7ejqIGY57xWGd6tre5JNhQfYnI/512G9hlJmmQ7/7mzY XTgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lFLzcJUo; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u21-20020a056a00159500b0051e77ab004fsi4203723pfk.10.2022.06.16.13.18.56; Thu, 16 Jun 2022 13:19:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lFLzcJUo; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378497AbiFPUSc (ORCPT + 99 others); Thu, 16 Jun 2022 16:18:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378403AbiFPUSU (ORCPT ); Thu, 16 Jun 2022 16:18:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77CC035872; Thu, 16 Jun 2022 13:18:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D83CF61D28; Thu, 16 Jun 2022 20:18:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07399C341C5; Thu, 16 Jun 2022 20:18:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655410697; bh=URKy9Zt/QltsQ+h+W4mrYiZ/kVoFvBb5ZeUzGoPXZow=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lFLzcJUofwsKTex6o428Z6VolGjmZN1oveS+3HiSv0NuCZ66QZ+5AW0m65muyZYen J2B4OfaiGJu0DhFxGwPPYE6dQWHqW6ZvyHK3azfYVO6XQGwdbCUx8SXalZOiI2w4TE WMRZfHuP2By2chQ47aDs8mrTpNRZxcDP/dmV7Npc+1deAUj7YkR4WWsOWuGizA/lCC DBF5JF8RlRB9WLSCbypGxvte96vrRF1JlT2LfxMY7PtUVPvSMJkfdxtNmtQMp+CTtk 8h0oHhngArgkswPusD0kX120GHhPBMgz5FPxFq3Cq/Q6I7BEEH7EVq4Pur02Xbwanh Jmt7Yx/qiV43w== From: Eric Biggers To: linux-fsdevel@vger.kernel.org Cc: linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org, linux-api@vger.kernel.org, linux-fscrypt@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Keith Busch Subject: [PATCH v3 5/8] f2fs: move f2fs_force_buffered_io() into file.c Date: Thu, 16 Jun 2022 13:15:03 -0700 Message-Id: <20220616201506.124209-6-ebiggers@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220616201506.124209-1-ebiggers@kernel.org> References: <20220616201506.124209-1-ebiggers@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,SUSPICIOUS_RECIPS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Eric Biggers f2fs_force_buffered_io() is only used in file.c, so move it into there. No behavior change. This makes it easier to review later patches. Signed-off-by: Eric Biggers --- fs/f2fs/f2fs.h | 45 --------------------------------------------- fs/f2fs/file.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 7869e749700fc..d187b7d7ed243 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -4426,17 +4426,6 @@ static inline void f2fs_i_compr_blocks_update(struct inode *inode, f2fs_mark_inode_dirty_sync(inode, true); } -static inline int block_unaligned_IO(struct inode *inode, - struct kiocb *iocb, struct iov_iter *iter) -{ - unsigned int i_blkbits = READ_ONCE(inode->i_blkbits); - unsigned int blocksize_mask = (1 << i_blkbits) - 1; - loff_t offset = iocb->ki_pos; - unsigned long align = offset | iov_iter_alignment(iter); - - return align & blocksize_mask; -} - static inline bool f2fs_allow_multi_device_dio(struct f2fs_sb_info *sbi, int flag) { @@ -4447,40 +4436,6 @@ static inline bool f2fs_allow_multi_device_dio(struct f2fs_sb_info *sbi, return sbi->aligned_blksize; } -static inline bool f2fs_force_buffered_io(struct inode *inode, - struct kiocb *iocb, struct iov_iter *iter) -{ - struct f2fs_sb_info *sbi = F2FS_I_SB(inode); - int rw = iov_iter_rw(iter); - - if (!fscrypt_dio_supported(inode)) - return true; - if (fsverity_active(inode)) - return true; - if (f2fs_compressed_file(inode)) - return true; - - /* disallow direct IO if any of devices has unaligned blksize */ - if (f2fs_is_multi_device(sbi) && !sbi->aligned_blksize) - return true; - /* - * for blkzoned device, fallback direct IO to buffered IO, so - * all IOs can be serialized by log-structured write. - */ - if (f2fs_sb_has_blkzoned(sbi)) - return true; - if (f2fs_lfs_mode(sbi) && (rw == WRITE)) { - if (block_unaligned_IO(inode, iocb, iter)) - return true; - if (F2FS_IO_ALIGNED(sbi)) - return true; - } - if (is_sbi_flag_set(F2FS_I_SB(inode), SBI_CP_DISABLED)) - return true; - - return false; -} - static inline bool f2fs_need_verity(const struct inode *inode, pgoff_t idx) { return fsverity_active(inode) && diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index bd14cef1b08fd..5e5c97fccfb4e 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -808,6 +808,51 @@ int f2fs_truncate(struct inode *inode) return 0; } +static int block_unaligned_IO(struct inode *inode, struct kiocb *iocb, + struct iov_iter *iter) +{ + unsigned int i_blkbits = READ_ONCE(inode->i_blkbits); + unsigned int blocksize_mask = (1 << i_blkbits) - 1; + loff_t offset = iocb->ki_pos; + unsigned long align = offset | iov_iter_alignment(iter); + + return align & blocksize_mask; +} + +static inline bool f2fs_force_buffered_io(struct inode *inode, + struct kiocb *iocb, struct iov_iter *iter) +{ + struct f2fs_sb_info *sbi = F2FS_I_SB(inode); + int rw = iov_iter_rw(iter); + + if (!fscrypt_dio_supported(inode)) + return true; + if (fsverity_active(inode)) + return true; + if (f2fs_compressed_file(inode)) + return true; + + /* disallow direct IO if any of devices has unaligned blksize */ + if (f2fs_is_multi_device(sbi) && !sbi->aligned_blksize) + return true; + /* + * for blkzoned device, fallback direct IO to buffered IO, so + * all IOs can be serialized by log-structured write. + */ + if (f2fs_sb_has_blkzoned(sbi)) + return true; + if (f2fs_lfs_mode(sbi) && (rw == WRITE)) { + if (block_unaligned_IO(inode, iocb, iter)) + return true; + if (F2FS_IO_ALIGNED(sbi)) + return true; + } + if (is_sbi_flag_set(F2FS_I_SB(inode), SBI_CP_DISABLED)) + return true; + + return false; +} + int f2fs_getattr(struct user_namespace *mnt_userns, const struct path *path, struct kstat *stat, u32 request_mask, unsigned int query_flags) { -- 2.36.1