From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5759912D758 for ; Sat, 28 Dec 2024 22:17:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735424249; cv=none; b=REnUW8jHZt5NhLP7guctMNaNEsqIiwCdqz0/PLO10CfhU0v795Ndfht0uiWyfBorptfzF08MpuiTh/eIaH5wK8PebSmBMVSDd7Y2ipKvCFtOwtXUMnbrD52De5z0XP8i3QVP/WFFfQ99s7DZKymg0jk1wccBX0zpbSs8BPoDAA8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735424249; c=relaxed/simple; bh=lEO+UbC4ocaAVqsDjSaxCDJuHRh1ebUarxKb8n7HoDM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LxavMW58NmvX6lmS5tSmqLv/aFGUwTRJS4HARaeSTN8F0wkU8K+kKAl+Zj9zq6zi3yd37zL6y3u57kuJf74vbjf2cLjWiZ0CM3qAn97sIeBjaBVnToYZ+VwHt3HswCwmLqY7MHgwF2yD/7b9ZQ9Bc/HqiDE6L1rj/6D3uUNMZ4s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fromorbit.com; spf=pass smtp.mailfrom=fromorbit.com; dkim=pass (2048-bit key) header.d=fromorbit-com.20230601.gappssmtp.com header.i=@fromorbit-com.20230601.gappssmtp.com header.b=TVF2rZmy; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fromorbit.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fromorbit.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fromorbit-com.20230601.gappssmtp.com header.i=@fromorbit-com.20230601.gappssmtp.com header.b="TVF2rZmy" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2162c0f6a39so111451885ad.0 for ; Sat, 28 Dec 2024 14:17:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20230601.gappssmtp.com; s=20230601; t=1735424246; x=1736029046; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=IZ129VWY3npg/e3sCrjFNNSft+JjjDx3ErRjyMihN80=; b=TVF2rZmy6Td6Q5npl3MENPmApGgZS6DX7ByHtIkdMc77zlPFQI4/5SFR45QR6rKVmH 7fdd+RoV84tvIVg1AVKzlYW1T5HIyXonX5bK/KcqbOZh0k1e7hIUH5t8/ZTrEsPwBQ2d NWBMCOzOFbafjLFJTffvsMYQnb8ZQ43uWqqsUtlBzWoWpmZrBlj+yKUCj58VCU1oK5o1 7n2Yo1XChowvNrw9J+TR83NBdZFcHwMm5nRfaEyzlASnj61qMvt+Qy4zDLKUvW3jDlT5 Vjp7sgxIFiPUyUxX1j9+pQycmkfUSXEhHnahr6oW6h01B2MN8US1AyTGuoZnQc83T626 GX5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735424246; x=1736029046; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=IZ129VWY3npg/e3sCrjFNNSft+JjjDx3ErRjyMihN80=; b=NVWViw5V3zm6Lvgh0sZsFBha8fXsUf39CV8KMLPSd0o8/doNI1lsuy720YBp6ibIhZ 9vHwK4yKyFvyRoIM17gwZ6TvOxhcDN5zYugeUvRT0YUmgbsn7GKRI8NtQqis/pqOAH+3 hWfYsCBZHSl3o+d9/lixq1MAPTGsLTiThfF12M95+Af5jbXwXqdAQG6jt3PV892aquTO itZWT9uGMaVoANjD8ZDR30ktTRAG7EvdKVj0hrRdREtyeB3LCXiSs7zsR5nYgw1xKzqZ nAyozkRIh7Hny8R5VeMv2rrC6A+qP7rSD68xNg/zuvYP/cbovtt+akC8OxKod2s8OBpz MmRQ== X-Forwarded-Encrypted: i=1; AJvYcCWTSznz1/yu8/ORSbmgcyPzgCIAcgSBjTgmkGh5qGwLAyOj8Nft2ZH3P0blCjWoSdkOVaPAUsbeyZTPPzE=@vger.kernel.org X-Gm-Message-State: AOJu0Yxal7Xvf2ZJYj5cF0NuNZeUiQIPjVLlKL5DoyHpe85X9iy5M+Wk DFv+AsCrti5Zjcwoasrh9adYKd3hd9LCAAYyE8d7f88TWyV1FhNJ7ZTwzU9azXc= X-Gm-Gg: ASbGncvmIIlNqgOrJIY/DzDeVzC6BFg0SpEP4xvXvUXpSSBHDZtoSN/lnKADKjl/bOn sW1XiG8C+mI6V756yER8Cmv5fj+tgdu1JYgJpe22XqMlY5TmQ2KgQEVGYQupJa3q63LUAs0Uz6m r5qBj15udYsErFelWC1kqMuvV0ukiT2q/3QikgKkQ+dV+3VHF2xzu9h3sPKncZn+RLLnVAJc7M0 /8opvsHx2y9WgYAVlqCqDF6zCceCDkRzF+6tkmLnrDE2EwsxJ9H3qe978l+rKpDU9B8aK5Ll05f pdyLtDR0ryMl80lSD78xyAmCcQOyWhQV X-Google-Smtp-Source: AGHT+IFJiy4ioeYTsqxF1/sp83aQq1iKCHAIGzl5ylEkwVRvegDsq6+zqy8usgWzMuOH1G/iafoDJw== X-Received: by 2002:aa7:8b43:0:b0:725:4915:c10 with SMTP id d2e1a72fcca58-72aa9addf8emr47463706b3a.10.1735424246545; Sat, 28 Dec 2024 14:17:26 -0800 (PST) Received: from dread.disaster.area (pa49-186-89-135.pa.vic.optusnet.com.au. [49.186.89.135]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8daf26sm16598790b3a.117.2024.12.28.14.17.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Dec 2024 14:17:25 -0800 (PST) Received: from dave by dread.disaster.area with local (Exim 4.98) (envelope-from ) id 1tRf7b-0000000GW1B-0dbg; Sun, 29 Dec 2024 09:17:23 +1100 Date: Sun, 29 Dec 2024 09:17:23 +1100 From: Dave Chinner To: Chi Zhiling Cc: djwong@kernel.org, cem@kernel.org, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, Chi Zhiling Subject: Re: [PATCH] xfs: Remove i_rwsem lock in buffered read Message-ID: References: <20241226061602.2222985-1-chizhiling@163.com> <2ab5f884-b157-477e-b495-16ad5925b1ec@163.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2ab5f884-b157-477e-b495-16ad5925b1ec@163.com> On Sat, Dec 28, 2024 at 03:37:41PM +0800, Chi Zhiling wrote: > > > On 2024/12/27 05:50, Dave Chinner wrote: > > On Thu, Dec 26, 2024 at 02:16:02PM +0800, Chi Zhiling wrote: > > > From: Chi Zhiling > > > > > > Using an rwsem to protect file data ensures that we can always obtain a > > > completed modification. But due to the lock, we need to wait for the > > > write process to release the rwsem before we can read it, even if we are > > > reading a different region of the file. This could take a lot of time > > > when many processes need to write and read this file. > > > > > > On the other hand, The ext4 filesystem and others do not hold the lock > > > during buffered reading, which make the ext4 have better performance in > > > that case. Therefore, I think it will be fine if we remove the lock in > > > xfs, as most applications can handle this situation. > > > > Nope. > > > > This means that XFS loses high level serialisation of incoming IO > > against operations like truncate, fallocate, pnfs operations, etc. > > > > We've been through this multiple times before; the solution lies in > > doing the work to make buffered writes use shared locking, not > > removing shared locking from buffered reads. > > You mean using shared locking for buffered reads and writes, right? > > I think it's a great idea. In theory, write operations can be performed > simultaneously if they write to different ranges. Even if they overlap, the folio locks will prevent concurrent writes to the same range. Now that we have atomic write support as native functionality (i.e. RWF_ATOMIC), we really should not have to care that much about normal buffered IO being atomic. i.e. if the application wants atomic writes, it can now specify that it wants atomic writes and so we can relax the constraints we have on existing IO... > So we should track all the ranges we are reading or writing, > and check whether the new read or write operations can be performed > concurrently with the current operations. That is all discussed in detail in the discussions I linked. > Do we have any plans to use shared locking for buffered writes? All we are waiting for is someone to put the resources into making the changes and testing it properly... -Dave. -- Dave Chinner david@fromorbit.com