Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp166029lqi; Wed, 6 Mar 2024 13:15:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWBJaihUMQaqJE6a2gnDHpCDzitKU5j1VLz+WbOWEl7feTZEw+AkVvJY/bC8TrMZf8klhnRvDh42P+iFB2qtd7QT4rqrbJkRq1X2+sGYA== X-Google-Smtp-Source: AGHT+IH6b+OyWENtB2d318D22a7s7/e/IXbSzL981Op1h+VoqO0kWKBDj+JFZ20Q3FptR4P92QRS X-Received: by 2002:a05:6512:503:b0:513:23da:9766 with SMTP id o3-20020a056512050300b0051323da9766mr153262lfb.55.1709759708906; Wed, 06 Mar 2024 13:15:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709759708; cv=pass; d=google.com; s=arc-20160816; b=XC23mFv8P5gWnSPwXjD/WsVe+wWUUDdzoM2E9MTDiz+JOiWHZ/OfictOOScZSDZd+O 6WESf1FlH+AW8UQqZpMTuEYBa2o3RzvsVZHGSbf0bcXD4f6RdBi3lc2PyYG5G1+AzZWJ +eAzjfshqrFOt/xxgEOWx+YRYW7L3qnM2/E63rivYSIJWLEQ16wO779NkiaYvw1ozieY ArFU6tZ1gJVGc5flMWgm2fBkMROEJ8+tN36N8SKpxkTeTopJQzSQ0fPdzie/WdHXiGcM oE9xrPMJtn04cagqlaWxPvYHPzz5cq1X0aeAGn0aKwggOrlhdKTRy5EN1r6d8xur+bgt NYsg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=eqhjGVQ8jE8dziHNEPcBuEnJh6YM6o6ZWh6K+R5yz1M=; fh=YHLdjKKahtL/yHcGKkCwbODa9enLS9LVv08x3aqcCAk=; b=XEltkTJ5tFBV8xOqjj61WnkwoLDkJrO3J6UJCo/xZQRkmCX9NTNf0nnd+62LwQCVMN udfI0aLVvdiP3O1p8v72/NhrGZ3xyhKc3Ul/rZom/66MUuDbiFRYo3DPLEIbJabepKZ0 mkZSYoq0jAstTkSGnGS4zehYwatr6nZk3G3n+54sOvominpJo6NcRhkMiWvgvBTObjgA CKWEHmk7W43bdF0dPvJ1tr1+5txFleVnJqPVBmJqoDUkJBg5E8Cxq8c2EMJy4yHSz3jF pKffeZh+6EY6ta467aM6dteozUwACNGHWCTkm4XuYy42lACZDKxVZHGgqWBPJZt5DFEO bEzg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=a5QMrMSk; arc=pass (i=1 spf=pass spfdomain=fromorbit.com dkim=pass dkdomain=fromorbit-com.20230601.gappssmtp.com dmarc=pass fromdomain=fromorbit.com); spf=pass (google.com: domain of linux-kernel+bounces-94579-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94579-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=QUARANTINE) header.from=fromorbit.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id dc19-20020a170906c7d300b00a445ca4baa0si5819775ejb.951.2024.03.06.13.15.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 13:15:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-94579-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=a5QMrMSk; arc=pass (i=1 spf=pass spfdomain=fromorbit.com dkim=pass dkdomain=fromorbit-com.20230601.gappssmtp.com dmarc=pass fromdomain=fromorbit.com); spf=pass (google.com: domain of linux-kernel+bounces-94579-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94579-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=QUARANTINE) header.from=fromorbit.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9027E1F22557 for ; Wed, 6 Mar 2024 21:15:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7B1071B275; Wed, 6 Mar 2024 21:14:54 +0000 (UTC) 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="a5QMrMSk" Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.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 2292C19BA2 for ; Wed, 6 Mar 2024 21:14:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709759693; cv=none; b=uYYA0NcLamFM9AabvOTxyziLKOfeZzPmQ4tRPq36+BV3oAZuJQzCkJ4yxkl5pgry/H0X7ameXsGgopiLO/QyDDjmBefZJvTCuyTI7PWWO/O0+2VYkWWIvvGFUa5kmXA5EYvdYAoSHAfPGf/+0yvqvIi8WB35Y00lD0mxWupyjNY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709759693; c=relaxed/simple; bh=HlvIehcW7DL2ZkTuZYSlHhQXYbpHC0zj0KWYZTviIpI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=DSp5BXpmwaItDvVaXaFZtLgZ1ReL1v2hoFQqL5DDfa9pvYtoRaxXMJqK4dcddA07y8h49RNOg4WdPUB+pCB0+uS3Tm1V7gglomJXxT7IQv4ser5BFv3K/pT/J+r5ziW0dMr5WNpSjJCCbZdzYEsgSv7fyCiFV4bVh3DEOJO7puI= 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=a5QMrMSk; arc=none smtp.client-ip=209.85.210.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 Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-6e63e9abf6aso148463b3a.2 for ; Wed, 06 Mar 2024 13:14:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20230601.gappssmtp.com; s=20230601; t=1709759691; x=1710364491; 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=eqhjGVQ8jE8dziHNEPcBuEnJh6YM6o6ZWh6K+R5yz1M=; b=a5QMrMSkCh6CKxSZp1aoMlsWOh1/LdslQA8sbOLyLO3ibrMd6x/h0JqfrHeUOgWa3J L2KBWDgR/51+DeX0Bp/LE2FiKIAdtDpbfigFomyfaR48wFJxkh19s7Uz/Cvg6F/lpdLh pfY3hnq6G4woDGNTNVlZ+kkcj5qJRCngnVAy+gkb868EWY5EU04VMoO1sIADCHOqt0pb 0dcvTCDjJerRPi3a5DXq74ZDszeyTNeI58Z29vZ1ArrGPUohsZW1UeNBPoG7+jIry6gX hmB5veaCo5PFqElLML5tRN7hI14+AHMRiFkTvu8fBtN2WcUyHORPEkKzNvapQJQmCyad L5vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709759691; x=1710364491; 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=eqhjGVQ8jE8dziHNEPcBuEnJh6YM6o6ZWh6K+R5yz1M=; b=LHPZHe23xJbq4dwyehYidNtA4lPoGB2Iu3nw1sybXEbj0V7H2GxVQHl1dFhsdDvyad yKKtyOSm2OFwbwIpHN7E8LQXzVPfkhofvUJLYQHRJZ33/LeHI5giNTNkdaKflZYUBy/u gJ7itBoQFvvV/jdrC2NFQ6CJ6HHnF9+dXZh3/ZLKReMJJBAIoQXwaUZRHH0jKCn3LOsm jObV6u2bGdu5fV1nXauPeiNYN/1/Cav+wn5+xk1GvRQuMkXbkluOEW3EivJ7kyuG6aLb g6FM7w1OD1tknoNDA38aTBvoZm6NF1R389H/NgcXcC/RnCA284sG01Y1/RAxWNvj3z+g HSvA== X-Forwarded-Encrypted: i=1; AJvYcCXMz0vJnyR+LAjMNWme2R2vIVbcCZWLfESkawIK7JwLyXY/eW0ovCoGXDyS6f9QRM2yzvv11g8qJ3vYTeAfTL9RwhjwhWbj4gysm5Nz X-Gm-Message-State: AOJu0YxGjfFZ90GOetCovJO29KDGJ4gGB2KM3tCq1AVBFOoSxMLrCOG6 0uKNHJYB1mEwps3LfLAQpifwpp4CT4vhzP3cX+4EPURwSFda2tNdU4E/EWSROOY= X-Received: by 2002:aa7:88cd:0:b0:6e5:561b:4670 with SMTP id k13-20020aa788cd000000b006e5561b4670mr18155480pff.30.1709759691277; Wed, 06 Mar 2024 13:14:51 -0800 (PST) Received: from dread.disaster.area (pa49-179-47-118.pa.nsw.optusnet.com.au. [49.179.47.118]) by smtp.gmail.com with ESMTPSA id y133-20020a62ce8b000000b006e45a0101basm12036767pfg.99.2024.03.06.13.14.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 13:14:50 -0800 (PST) Received: from dave by dread.disaster.area with local (Exim 4.96) (envelope-from ) id 1rhybA-00Fy7Q-1A; Thu, 07 Mar 2024 08:14:48 +1100 Date: Thu, 7 Mar 2024 08:14:48 +1100 From: Dave Chinner To: John Garry Cc: djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, axboe@kernel.dk, martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com, ritesh.list@gmail.com, linux-block@vger.kernel.org Subject: Re: [PATCH v2 07/14] fs: iomap: Sub-extent zeroing Message-ID: References: <20240304130428.13026-1-john.g.garry@oracle.com> <20240304130428.13026-8-john.g.garry@oracle.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: <20240304130428.13026-8-john.g.garry@oracle.com> On Mon, Mar 04, 2024 at 01:04:21PM +0000, John Garry wrote: > For FS_XFLAG_FORCEALIGN support, we want to treat any sub-extent IO like > sub-fsblock DIO, in that we will zero the sub-extent when the mapping is > unwritten. > > This will be important for atomic writes support, in that atomically > writing over a partially written extent would mean that we would need to > do the unwritten extent conversion write separately, and the write could > no longer be atomic. > > It is the task of the FS to set iomap.extent_shift per iter to indicate > sub-extent zeroing required. > > Maybe a macro like i_blocksize() should be introduced for extent sizes, > instead of using extent_shift. It would also eliminate excessive use > of xfs_get_extss() for XFS in future. > > Signed-off-by: John Garry > --- > fs/iomap/direct-io.c | 14 ++++++++------ > include/linux/iomap.h | 1 + > 2 files changed, 9 insertions(+), 6 deletions(-) > > diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c > index bcd3f8cf5ea4..733f83f839b6 100644 > --- a/fs/iomap/direct-io.c > +++ b/fs/iomap/direct-io.c > @@ -277,7 +277,7 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, > { > const struct iomap *iomap = &iter->iomap; > struct inode *inode = iter->inode; > - unsigned int fs_block_size = i_blocksize(inode), pad; > + unsigned int zeroing_size, pad; > loff_t length = iomap_length(iter); > loff_t pos = iter->pos; > blk_opf_t bio_opf; > @@ -288,6 +288,8 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, > size_t copied = 0; > size_t orig_count; > > + zeroing_size = i_blocksize(inode) << iomap->extent_shift; The iomap interfaces use units of bytes for offsets, sizes, ranges, etc. Using shifts to define a granularity value seems like a throwback to decades old XFS code and just a bit weird nowdays. Can we just pass this as a byte count? i.e.: zeroing_size = i_blocksize(inode); if (iomap->extent_size) zeroing_size = iomap->extent_size; Cheers, Dave. -- Dave Chinner david@fromorbit.com