From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54633C4332F for ; Tue, 16 Nov 2021 21:45:34 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B374861A64; Tue, 16 Nov 2021 21:45:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B374861A64 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.94.2) (envelope-from ) id 1mn6Gi-0002DQ-56; Tue, 16 Nov 2021 21:45:32 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mn6Gh-0002DJ-22 for linux-f2fs-devel@lists.sourceforge.net; Tue, 16 Nov 2021 21:45:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=FFnBZHC4ZMR4lijKkzE8F1y2QxKC3ZthlTZX8wE3o60=; b=CK0TD1JzSnU5WGGvujhh/mDWZu HIyO3I2V9h3o5bVbg0yR4u9MybPb+bEvsxIZC3ZgaNdi1H/vbAgflvZBeOLz3QCEtrjHA+uqEq2Wx 6R6A3DgkMrJgY+I9O3LwEVDQ3xhRyHnu24owtFBsffQjoFVZwXdgjSLWz27GWuQYmZQ4=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=FFnBZHC4ZMR4lijKkzE8F1y2QxKC3ZthlTZX8wE3o60=; b=mU36XUTp1BcY7jTQMnivwlBP2J PDyuio7wJSPceSzoUv7bIyX0sjoWf15G1vGfLt0Gq6I9Iw83i7ULst/LptD+ahVU4zjXoLamjpN+E 3cwerSenq8/siX8i5lTqfuo7frj3nFsYuYuG/JcM6LxTXLKuqCJtQG9ks69Znj87MnRY=; Received: from mail.kernel.org ([198.145.29.99]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) id 1mn6Gd-00FLny-60 for linux-f2fs-devel@lists.sourceforge.net; Tue, 16 Nov 2021 21:45:30 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id DCE5263223; Tue, 16 Nov 2021 21:45:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1637099119; bh=G0xhnbWO+0WlA4XzuUY22qQyT/4Oct37q6Qk4qrlL3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L+++ZzzgIqughHSH8UG6yEyqdHMnwr7hJ59i1RwAl+Vf1/7nmO8+2j1edEo/hpfEg F16fYtsXMHyQUgTRx4Jv1AukrfLIxEk0A6XbjjnZy8kuPYqXEd6M5duYO5TlOK2o2x flfURNCC8is7aB6T4AvQAqcpKIVNSf7Np9FwCfJZ/V954Zw8LznUszcV+YlK+SWfen amE22SXvnVYw9/MFL4+thegvQnR/pXYYWkWyEhq8cQgumNbV8KKWGmbzfEJ/bv/LUH Y/6aBHdQn0fqCHpcBWyC/rc7hoios1Tw2sKwvuUMfWMvEHT2T0S+CbhnheCDr3cjYk cFyaOAjjA3i1Q== From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Date: Tue, 16 Nov 2021 13:45:07 -0800 Message-Id: <20211116214510.2934905-3-jaegeuk@kernel.org> X-Mailer: git-send-email 2.34.0.rc1.387.gb447b232ab-goog In-Reply-To: <20211116214510.2934905-1-jaegeuk@kernel.org> References: <20211116214510.2934905-1-jaegeuk@kernel.org> MIME-Version: 1.0 X-Headers-End: 1mn6Gd-00FLny-60 Subject: [f2fs-dev] [PATCH 3/6] f2fs: reduce indentation in f2fs_file_write_iter() X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jaegeuk Kim , Eric Biggers Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net From: Eric Biggers Replace 'if (ret > 0)' with 'if (ret <= 0) goto out_unlock;'. No change in behavior. Signed-off-by: Eric Biggers Signed-off-by: Jaegeuk Kim --- fs/f2fs/file.c | 69 ++++++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 33 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index ec8de0662437..fdc440d212c3 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -4355,48 +4355,51 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) } ret = generic_write_checks(iocb, from); - if (ret > 0) { - if (iocb->ki_flags & IOCB_NOWAIT) { - if (!f2fs_overwrite_io(inode, iocb->ki_pos, - iov_iter_count(from)) || + if (ret <= 0) + goto out_unlock; + + if (iocb->ki_flags & IOCB_NOWAIT) { + if (!f2fs_overwrite_io(inode, iocb->ki_pos, + iov_iter_count(from)) || f2fs_has_inline_data(inode) || f2fs_force_buffered_io(inode, iocb, from)) { - ret = -EAGAIN; - goto out_unlock; - } - } - if (iocb->ki_flags & IOCB_DIRECT) { - ret = f2fs_convert_inline_inode(inode); - if (ret) - goto out_unlock; - } - /* Possibly preallocate the blocks for the write. */ - target_size = iocb->ki_pos + iov_iter_count(from); - preallocated = f2fs_preallocate_blocks(iocb, from); - if (preallocated < 0) { - ret = preallocated; + ret = -EAGAIN; goto out_unlock; } + } - ret = __generic_file_write_iter(iocb, from); + if (iocb->ki_flags & IOCB_DIRECT) { + ret = f2fs_convert_inline_inode(inode); + if (ret) + goto out_unlock; + } + /* Possibly preallocate the blocks for the write. */ + target_size = iocb->ki_pos + iov_iter_count(from); + preallocated = f2fs_preallocate_blocks(iocb, from); + if (preallocated < 0) { + ret = preallocated; + goto out_unlock; + } - /* Don't leave any preallocated blocks around past i_size. */ - if (preallocated > 0 && i_size_read(inode) < target_size) { - down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); - filemap_invalidate_lock(inode->i_mapping); - if (!f2fs_truncate(inode)) - file_dont_truncate(inode); - filemap_invalidate_unlock(inode->i_mapping); - up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); - } else { + ret = __generic_file_write_iter(iocb, from); + + /* Don't leave any preallocated blocks around past i_size. */ + if (preallocated > 0 && i_size_read(inode) < target_size) { + down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); + filemap_invalidate_lock(inode->i_mapping); + if (!f2fs_truncate(inode)) file_dont_truncate(inode); - } + filemap_invalidate_unlock(inode->i_mapping); + up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); + } else { + file_dont_truncate(inode); + } - clear_inode_flag(inode, FI_PREALLOCATED_ALL); + clear_inode_flag(inode, FI_PREALLOCATED_ALL); + + if (ret > 0) + f2fs_update_iostat(F2FS_I_SB(inode), APP_WRITE_IO, ret); - if (ret > 0) - f2fs_update_iostat(F2FS_I_SB(inode), APP_WRITE_IO, ret); - } out_unlock: inode_unlock(inode); out: -- 2.34.0.rc1.387.gb447b232ab-goog _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel