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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20238C433F5 for ; Tue, 15 Mar 2022 12:19:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348191AbiCOMUQ (ORCPT ); Tue, 15 Mar 2022 08:20:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348185AbiCOMUP (ORCPT ); Tue, 15 Mar 2022 08:20:15 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45FB7527CC for ; Tue, 15 Mar 2022 05:19:03 -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 ams.source.kernel.org (Postfix) with ESMTPS id DE124B815E9 for ; Tue, 15 Mar 2022 12:19:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B96FC340ED for ; Tue, 15 Mar 2022 12:18:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647346740; bh=N1uGgZ7jpmB97xU/FjNjDPP7MCBs2/e+l7l5TUpFegg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=UhdR4GXFtpkxgCS8Sm60jvwJD0ydtdmzAQYBUJdb7Str+GK8WrCrZm6PxGAuvOxN1 bfzX+wiHuJMcD+eKS8IJBj7cQMnazMo7L/ODCDRS1QSs5yeumxGg7upTtCYeYbA0i2 KaUSHc/djQAV6IplhVs/nDeJhZo4FFONwHs1X2T+aDPtUHliCYhVu2L5lP9M5I7PsA d2FjJAkO6hNpSKRbqXJDA0KLOA1kBUOfd6D7OcA3lVUuH8v+GWL/CetR2qGCvlpkwS xPU8r16/ZdriASdJ4WFhCWzOY3AGj0WjFZoZWn+fD3bBH5zJHTvjLekbH0nYvEpY/+ q+liLPS7hJx2Q== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 3/7] btrfs: remove inode_dio_wait() calls when starting reflink operations Date: Tue, 15 Mar 2022 12:18:50 +0000 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Filipe Manana When starting a reflink operation we have these calls to inode_dio_wait() which used to be needed because direct IO writes that don't cross the i_size boundary did not take the inode's VFS lock, so we could race with them and end up with ordered extents in target range after calling btrfs_wait_ordered_range(). However that is not the case anymore, because the inode's VFS lock was changed from a mutex to a rw semaphore, by commit 9902af79c01a8e ("parallel lookups: actual switch to rwsem"), and several years later we started to lock the inode's VFS lock in shared mode for direct IO writes that don't cross the i_size boundary (commit e9adabb9712ef9 ("btrfs: use shared lock for direct writes within EOF")). So remove those inode_dio_wait() calls. Signed-off-by: Filipe Manana --- fs/btrfs/reflink.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c index 04a88bfe4fcf..bbd5da25c475 100644 --- a/fs/btrfs/reflink.c +++ b/fs/btrfs/reflink.c @@ -771,7 +771,6 @@ static int btrfs_remap_file_range_prep(struct file *file_in, loff_t pos_in, struct inode *inode_in = file_inode(file_in); struct inode *inode_out = file_inode(file_out); u64 bs = BTRFS_I(inode_out)->root->fs_info->sb->s_blocksize; - bool same_inode = inode_out == inode_in; u64 wb_len; int ret; @@ -809,15 +808,6 @@ static int btrfs_remap_file_range_prep(struct file *file_in, loff_t pos_in, else wb_len = ALIGN(*len, bs); - /* - * Since we don't lock ranges, wait for ongoing lockless dio writes (as - * any in progress could create its ordered extents after we wait for - * existing ordered extents below). - */ - inode_dio_wait(inode_in); - if (!same_inode) - inode_dio_wait(inode_out); - /* * Workaround to make sure NOCOW buffered write reach disk as NOCOW. * -- 2.33.0