From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.208.174 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795957838; b=OqHZR5T7LtH6odfaTWOjSZWHX1ISFBM7fE7FDgvek4wgTd0K8SdTFPMuTxsVS3rOyN/q wx/7kLFCdq9ifmKs/6Mqbl1p523esSxkJEuKtmto7uI+2gzxgBugOAN1HVnCnHXCauVQj mNBBZmlJ3TP4GFeZ73/XPVgzrix5Fm1doIjUu9bz0Zi7m4Ft5MJA20vqpyRjnAWvo3m+r TlAZ/CsHAp/FJ18VMP76uism54N74/7ZPcL/Un5AbBMSg9fyAIvH4WzBjQE2/JRojzURJ ytCoGX19vdnC+JXoit5j2PeiPFvO5UlGnQ8lDEYM7Wd1yE/09rRfCIMHkEG6X52ZEUg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795957838; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=40SoilEFJD1KLyo0u6fuFjRTobROX8sdbcMWh/KVnyU=; b=Azh7rVe8NHg8LcoDyIBeb6+Zk5Bla6twmOQ41Nk33rWtzSjAxtxF+mqwX7LYKMI3yVyl AMjSWhAqewn9Eni7SVGeHrnmFccuNV5B2pHzwn+BF8kJXouXCuPGMSyZtrMwCyMLAvLdw YBIGroIMDKhwxXeJRfHXbfMeiqLujQl/lFZBd0t+o38jifE5jX/2e/yNxgTLrjDoZSumY 7lSdj7TgPnzAEpJkMJIzv/6kWjYezfTHacnMAgU2e66TvpQ0OzHzVmjCqIJww3SqNJXzl DD2FvyhIiPcyu7Vc7NDyLcc8/UnqOLKvL6DPithQpuh9D8Lg0GwhGIWKaOR4b3yzY/g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=q2f9UMwH; arc=none smtp.remote-ip=209.85.208.174 Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8686D606A32C for ; Sun, 29 Nov 2026 13:10:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8686D606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=q2f9UMwH Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-3ab3b29a1d4so76426471fa.1 for ; Sun, 29 Nov 2026 05:10:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795957837; x=1796562637; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=40SoilEFJD1KLyo0u6fuFjRTobROX8sdbcMWh/KVnyU=; b=q2f9UMwH0PYqycAYAj27HNkv10Mv/8pkPhTpxhgaM2guXNxhajrE8n83Yu+Y/19Zb+ jhxWP4qifxcquuJtVf9Pc3mwXD/tflmNPxE7Jje9RPZzdEQvFl4ZCMPyUDdkCjWtUGch AE+ZGdpGZL80na3dxFgMAe0D1YK4bQ9axJgqWQ1RrISDd/QeDMyvXKSdxLrN0Iay4Y5C pAobbN89q2TcxdlQQQoPWXpirJCR+Yu0IP7vXHjVnyWSzvydmiweUpEzIEZl5q4lbmzz MBbpJsyNO2WtE9ybqtPDeFfsMUxcvi7WVWDB1wxqCb6GeqbqfrtYw1uwUBev44Uy+of5 NZFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795957837; x=1796562637; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=40SoilEFJD1KLyo0u6fuFjRTobROX8sdbcMWh/KVnyU=; b=zf0nIiyP0KlbBR7z4KFUeprKATkJYb/nhahkCGbw/RrmnBozcHTOj3XP0nWjjxpujA +kXn1rqBT+PeRhU9qwYJPqWiSTN+XoOjDxZuZHGBKpbH+GfmcyoO8g5x9OfFqBo+C/la 7yMLtYF9ccETmLJxPj2tvE8DGbSGDNmlL+f8F3SblOYQTCURU7ZvbNJOHVWzwA/JQtZ3 dwpLS2dGuD5hAW+X4StOGpMJSwRAUV7LL1UiVqqKZe5L8Hwuz3nyvTCIL5qqr5oklUMx GCTwFgEw+xArlf0NrDSOYMpHZt+qTTwkE9OVFDqZIQPcBkeNCLN3VOVlX6euYwYHxGb2 hhSw== X-Forwarded-Encrypted: i=1; AL+hErGNk0JZMq40vfxSK/bo3wugWAira6uXuDVIXSvqlxdWO7uQdtZMWRyPzK3mkGridXiB++qzNHFqogw=@vger.kernel.org X-Gm-Message-State: APuU4Z8yDrw191tGe7OdGRFGUX7JDaMAkPGuvCd4U4FmctMsJDdStyDQ pdmXz+NtjAl4K3pH2JNwMhTUSrN9av/2QQsGfq8Q6WLAMJyG/LCgCeud X-Gm-Gg: AZFdTZfmBBivTBbp72LALeHA+OA/iQm1S/3lACIh7gTHy05K13M/clf/J7B2Gtg+lfq +ssAnQ9pjORbU46mJh3FFwSsLM8NQOsz4IxmcG+f2kA8e4jNjh0QDVLA4B4KptLxbyVKEPolzsR m1lpG/mg6oPGUybQAaUdMfsKLr1G+lj0Zjy8ztlkRofpoLi1FpgDBzmb3TvNPGHkdLG3slnoRSD ZWBwCjnHJRpxQieJFzslQQ7Lz2ZwycpxbNZbIOjy+E3eQ+7vzZXQluhAeYEJGg5DFIrn9J5vh5/ tWVQ5mA/9ckd1ITlbj6AEOgWObSgfTYpZLaj1n8NSuXUByHlO6e2gDt2UGt/nGtLK4H4yszKIt/ x6DgJyZ6LZZW8JArpD7Ut5sgbDLjnNK61yVDlDwTfqFBHXPHV6CYyLIaruGza2CwocvyTSPpIaq Sz01JD4iEGvihRBapWPXNNWtXSCB3HTxBhWUNOUggFPUBN0BFoyFOS9W1xxR5Dl89RsmH6VKvOR wg9XTg65Dw4lgvOLGFkzRPXwXuwOZTzeMYPo5fka5PE4hbroP3MR0gRnzWPhA33T0EEssIKpRlK 8BMpGg8Nr/GoknZblIZhYRIT6CXHSAzVE+X0MdfBDPkv65aZIkbKg82fmrM3yNCB+g6KEJ78f9a t0nrDth4pT16e66MVSEW8HoyA4I538gvDCuL+EqDhf+7TMcaG4RakWR9KvP8= X-Received: by 2002:a05:6512:401d:b0:5c3:38ba:937b with SMTP id 2adb3069b0e04-5c338ba94bamr2805257e87.36.1795957836439; Sun, 29 Nov 2026 05:10:36 -0800 (PST) Received: from Lauri-G-Pro-14-M4.intra.lakuz.com (n2vuxeelhjcjzleaeka-1.v6.elisa-laajakaista.fi. [2001:99a:2ab:bb00:297d:e668:90c3:9a3a]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-3ae8050fdeasm80640031fa.15.2026.11.29.05.10.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 29 Nov 2026 05:10:36 -0800 (PST) From: Lauri Gates To: koraynilay Cc: Namjae Jeon , Hyunchul Lee , Jonathan Corbet , Eric Biggers , "Theodore Y . Ts'o" , Jaegeuk Kim , Alexander Viro , Christian Brauner , Shuah Khan , Randy Dunlap , Chuck Lever , Jeff Layton , Jan Kara , Alexander Aring , "Darrick J . Wong" , Andrey Albershteyn , Amir Goldstein , Miklos Szeredi , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Christoph Hellwig , Dave Chinner , linux-btrfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, ntfs@lists.linux.dev, linux-nfs@vger.kernel.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, linux-unionfs@vger.kernel.org Subject: Re: [PATCH v3 2/5] vfs: add xflags masks to fileattr API Date: Sun, 29 Nov 2026 15:10:24 +0200 Message-ID: <20261129131024.92875-1-lauri.gates@gmail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261129024233.2361718-3-koray.fra@gmail.com> References: <20261129024233.2361718-3-koray.fra@gmail.com> X-Mailing-List: linux-api@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Sun, Nov 29, 2026 at 03:42:30AM +0100, koraynilay wrote: > + if (fa->flags_valid) { > + /* > + * Assume that if the filesystem supports masks it supports its > + * writable FS_*_FL flags via FS_XFLAG_* and fsx_xflags_rw_mask. > + */ > + changed = fa->flags ^ old_ma->flags; > + if (changed & ~xflags_to_flags(old_ma->fsx_xflags_rw_mask)) > + return -EOPNOTSUPP; I would like to ask for a change here before v4: let FS_IOC_SETFLAGS keep working for flags that the rw mask cannot express, instead of failing with EOPNOTSUPP. A sketch and the reason follow; would you take something like it? I ran into this assumption while putting the may-share flag from the FIEMAP thread [1] on top of v3, in a series I have not posted yet. The flag is read-only, so it is reported through fa_xflags_ro_mask, which the VFS fills only when the filesystem sets has_masks. My series therefore sets has_masks for ocfs2 as well as xfs. On ocfs2 that broke FS_IOC_SETFLAGS for six flags it accepts today. Five have no FS_XFLAG_* counterpart: SECRM, UNRM and NOTAIL on files, DIRSYNC and TOPDIR on directories. The sixth is COMPR, whose xflag from 3/5 is read-only, so it can never be in fsx_xflags_rw_mask. Each set failed with EOPNOTSUPP (QEMU, v7.4-rc1 plus v3 1-3 and my series); without my series all six work. ocfs2 is only the first case. Of the filesystems in v3 only ntfs sets has_masks, but ext4 (DIRSYNC, TOPDIR, JOURNAL_DATA, EXTENTS) and btrfs (DIRSYNC, NOCOW) have the same kind of flags, so neither could set it without losing chattr for them. COMPR on btrfs is the case Amir asked to footnote in 5/5 as "RW only via SETFLAGS": with masks, chattr +c would fail the same way, and the footnote would no longer be true. With the fallback below it stays true. FS_IOC_FSSETXATTR is not affected, since it has never been able to set these flags. The sketch, against v3 2/5: when an FS_IOC_SETFLAGS call changes a flag that the rw mask cannot express, give the filesystem the full read-modify-write request it got before masks. The check quoted above can then never fire, so the sketch removes it: --- a/fs/file_attr.c +++ b/fs/file_attr.c @@ static int fileattr_set_rmw_to_mask(struct file_kattr *fa, if (fa->flags_valid) { - /* - * Assume that if the filesystem supports masks it supports its - * writable FS_*_FL flags via FS_XFLAG_* and fsx_xflags_rw_mask. - */ - changed = fa->flags ^ old_ma->flags; - if (changed & ~xflags_to_flags(old_ma->fsx_xflags_rw_mask)) - return -EOPNOTSUPP; - - changed = flags_to_xflags(changed); + changed = flags_to_xflags(fa->flags ^ old_ma->flags); } else { /* if (fa->fsx_valid) */ @@ static int fileattr_set_convert(struct file_kattr *fa, - if (old_ma->has_masks) + /* + * A masked request names only flags with an FS_XFLAG_* counterpart. + * FS_IOC_SETFLAGS changing any other flag (e.g. FS_DIRSYNC_FL) gets + * the full request below, which the filesystem handled before masks. + */ + if (old_ma->has_masks && + !(fa->flags_valid && ((fa->flags ^ old_ma->flags) & + ~xflags_to_flags(old_ma->fsx_xflags_rw_mask)))) return fileattr_set_rmw_to_mask(fa, old_ma); With it, all six ocfs2 flags set and clear again, and nothing else in my xfs, ocfs2 and overlayfs checks changes. The cost is in the contract: a filesystem that sets has_masks must still accept a full, unmasked request from FS_IOC_SETFLAGS. Every ->fileattr_set() does today, because has_masks on set is new in this series, but the documentation in 5/5 would need to say so. The other way I can see is to keep the masked request and pass the unmapped FS_*_FL changes beside it, which needs a second mask. That seems like more API than the case needs, so I would go with the fallback. [1] https://lore.kernel.org/linux-xfs/20261102193533.93690-1-lauri.gates@gmail.com/ Lauri