Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp340521pxb; Wed, 27 Oct 2021 04:05:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKLdZUo5e4ZyYHcddNNrJR7a94CrpwTSv3Depadl4D7PWFkEe96t/LRhYiUOjdnCv0gNcq X-Received: by 2002:a17:907:72cc:: with SMTP id du12mr3408242ejc.421.1635332704618; Wed, 27 Oct 2021 04:05:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635332704; cv=none; d=google.com; s=arc-20160816; b=fczTJ4OINH4KDJkchhCFtnpEqWoksBGw6lH13v3M/1z6ASgx17SXBwoSGIbmE+c26A W/hhhqND+hpiJ6neEDYDatcH/ZFGzDWg8sWrrxMwf7lOuFpcfull4Kys0IC5371i03gA IY55ebXzfbiULG6Y8fTVLf63N5GAFS/BuLrF1PruAQhMmCt548HSTS997tsw891xGZ7V N7Fbl0BbohIJsQJA71LmW07hwciu0iDSqAcu+uZOPLEBIDurwcwfX9kBxviERnOwy+j2 3ob+hoFk7uX89h/qTSUUh/tbRVY/dOVvt/rTDfyDtYzaHiLn4o/aoUAnj5xTeJitd5EW lFaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=TnJ2YRVn5xDp4l5KcZcW6tPRwDMAjXYMkP8cTWZSwa0=; b=Il7m3uEkxiN3Q0ZE/l0HZAWHf/xQR4RG9rrvhvFcQrO5QzyiXTNnFAjnDkvyE9KTBu TzKyT3maivUzslYD9y5Re5zSb44ZyQ/kqJXydXaWBhnt0ly50qHealAw1npHGWec1DqK xfz0wgXiQ0WrkLNSavX7ZDupBYuaDRmMjGkpeAgsQy6Eki0WBtFxELZfeCjEjMob0p5M Da6GnmJNd/4CsJ6xe8lcEKr+xM2a4QLScbQkE89D91E/4KRmREq89TOGB5M9mlKbLZ14 rlotDxZsbivj+lEYuozCMbBdwOM/izJdqBcIWLH5otNXhEFIOLzEYfNywwtkN/UNFXpU q4XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cFRrZ2gr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g1si4912976ejt.262.2021.10.27.04.04.40; Wed, 27 Oct 2021 04:05:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cFRrZ2gr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237160AbhJZVVi (ORCPT + 99 others); Tue, 26 Oct 2021 17:21:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237133AbhJZVVT (ORCPT ); Tue, 26 Oct 2021 17:21:19 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFEB0C061745; Tue, 26 Oct 2021 14:18:54 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id x192so1526952lff.12; Tue, 26 Oct 2021 14:18:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=TnJ2YRVn5xDp4l5KcZcW6tPRwDMAjXYMkP8cTWZSwa0=; b=cFRrZ2grRE8nhwbq07zLQccMhZ8FcSyluojgZX5VnyTxW1YvGgJcA8XKr16suhGoZe XVxxnI28MdGNq2YU+0M0XFIFIeY6os3fQRMnyXhpaQnbGGKWG16KYAHnj+2XV+U78OC7 +yCjLqpYnT59MLqfesVX7ad4eWFregVlqpj1DpY+0yUjQx1BjD37TC6A2t4+S6uHSLo8 fCzTO4MVd0EcSgxiNIt7r8myO8KJ3wuveS1pq6zdVgrxJFLGn40kbXHoMewqLaZ+Sdyh ILH5Bp70G73dzI9389X0NuiAQUt0xY0ZyI6ZL4Evrvgwasx75Ov6W04uArsSr7gaL4YG TdBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=TnJ2YRVn5xDp4l5KcZcW6tPRwDMAjXYMkP8cTWZSwa0=; b=2TD+jNv+qzF1jZUDKD/+enNiMMCBKgbJoCg2HPxS9qLVgnx6yiJ8Doj7NJdPj8c50L ++Q4h/usnbtb8gaI3BWetIwr1ly1OqR0GuKjlCAFeDNqBAXJB3wxdbGsNDXWw4Hb6Eb+ NqF80NaDx+5xIu8DeTOXi4ocM0KzNe1R85vgqKy9qnl1RcBs4NPGeknwKO2xgShrQEaW MwmRpkvb8Fi5XIfOvuzCYbER6203nBVptoxpM0CmyfBvEFNLRtunGVW5WO8jpszG2gyP n+6lDaYqZKyNAmx+tmXBfBsqJVM4FBH9GAF1k5JLOgBbruAQlsrcLFx4AEgHlLadsIjH ccww== X-Gm-Message-State: AOAM53086xSU8LO7Qycsb4Pwjg3cFrUgKfT8GtlfCMjsJ5TlE0PcaWpt MXZXmR04uIonfJ2KsDuQLP6rddV9PY0= X-Received: by 2002:ac2:44ad:: with SMTP id c13mr17950336lfm.688.1635283133300; Tue, 26 Oct 2021 14:18:53 -0700 (PDT) Received: from kari-VirtualBox ([31.132.12.44]) by smtp.gmail.com with ESMTPSA id c19sm2110051ljj.130.2021.10.26.14.18.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Oct 2021 14:18:52 -0700 (PDT) Date: Wed, 27 Oct 2021 00:18:51 +0300 From: Kari Argillander To: Konstantin Komarov Cc: ntfs3@lists.linux.dev, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 2/4] fs/ntfs3: Fix fiemap + fix shrink file size (to remove preallocated space) Message-ID: <20211026211851.merrsc662mhzqghm@kari-VirtualBox> References: <25b9a1b5-7738-7b36-7ead-c8faa7cacc87@paragon-software.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 25, 2021 at 07:58:57PM +0300, Konstantin Komarov wrote: > Two problems: > 1. ntfs3_setattr can't truncate preallocated space; > 2. if allocated fragment "cross" valid size, then fragment splits into two parts: > - normal part; > - unwritten part (here we must return FIEMAP_EXTENT_LAST). > Before this commit we returned FIEMAP_EXTENT_LAST for whole fragment. > Fixes xfstest generic/092 I do not have time for now to got through more. Maybe you have some ideas here. generic/092 [21:16:19][ 18.906951] run fstests generic/092 at 2021-10-26 21:16:19 [21:16:22]- output mismatch (see /results/ntfs3/results-default/generic/092.out.bad) --- tests/generic/092.out 2021-08-03 00:08:10.000000000 +0000 +++ /results/ntfs3/results-default/generic/092.out.bad 2021-10-26 21:16:22.127859289 +0000 @@ -2,5 +2,6 @@ wrote 5242880/5242880 bytes at offset 0 XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 0: [0..10239]: data +1: [10240..20479]: unwritten 0: [0..10239]: data 1: [10240..20479]: unwritten Argillander > Fixes: 4342306f0f0d ("fs/ntfs3: Add file operations and implementation") > > Signed-off-by: Konstantin Komarov > --- > fs/ntfs3/file.c | 2 +- > fs/ntfs3/frecord.c | 10 +++++++--- > 2 files changed, 8 insertions(+), 4 deletions(-) > > diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c > index 43b1451bff53..5418e5ba64b3 100644 > --- a/fs/ntfs3/file.c > +++ b/fs/ntfs3/file.c > @@ -761,7 +761,7 @@ int ntfs3_setattr(struct user_namespace *mnt_userns, struct dentry *dentry, > } > inode_dio_wait(inode); > > - if (attr->ia_size < oldsize) > + if (attr->ia_size <= oldsize) > err = ntfs_truncate(inode, attr->ia_size); > else if (attr->ia_size > oldsize) > err = ntfs_extend(inode, attr->ia_size, 0, NULL); > diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c > index 6f47a9c17f89..18842998c8fa 100644 > --- a/fs/ntfs3/frecord.c > +++ b/fs/ntfs3/frecord.c > @@ -1964,10 +1964,8 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo, > > vcn += clen; > > - if (vbo + bytes >= end) { > + if (vbo + bytes >= end) > bytes = end - vbo; > - flags |= FIEMAP_EXTENT_LAST; > - } > > if (vbo + bytes <= valid) { > ; > @@ -1977,6 +1975,9 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo, > /* vbo < valid && valid < vbo + bytes */ > u64 dlen = valid - vbo; > > + if (vbo + dlen >= end) > + flags |= FIEMAP_EXTENT_LAST; > + > err = fiemap_fill_next_extent(fieinfo, vbo, lbo, dlen, > flags); > if (err < 0) > @@ -1995,6 +1996,9 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo, > flags |= FIEMAP_EXTENT_UNWRITTEN; > } > > + if (vbo + bytes >= end) > + flags |= FIEMAP_EXTENT_LAST; > + > err = fiemap_fill_next_extent(fieinfo, vbo, lbo, bytes, flags); > if (err < 0) > break; > -- > 2.33.0 > > >