From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.169 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796101012; b=qm+Va6a2Xe9oGufhWQUrVhAQtNzRLWo22KqP3SiF0Mda0hBj3ESuGDexLUXKyycs1jHP K+gfqtORQ14rtG73s6YWgTR1KDnBDUrxD96V1DNU18o2vQl+/w/GrsyAOg5oN5xlJ1ij9 lN2Lv/x0PJ5rlPshyuIFLwcNuHXXkc9BBB71qvpEuKw6Zi9NSssH7/2F7s3Ta3pz9QyPS EyoCkkTimiajFgGj1RLpo5BB5mLtb+IBZzLLtk1Ll/rA9xy2gD2YuiezGyJbYIIowfT5c vHbO2vE8PN8aCKfuUybEiwrVPWmlfPChcIRfXTg1bPs7wahPuhUQh7tAgIKK85SoAUQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796101012; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Content-Type:Date:Message-Id:Cc:Subject:From:To:In-Reply-To: References:Content-Transfer-Encoding:MIME-Version; bh=FGKT9ChZb7WhrEMVqsSmd5I4ABpOcbDEQWGXPM/PImc=; b=cEZSxBsHoGL7OQ213KiSETDKYOnzH3D4KW8dzTIZ3+j9m/M9Ack5bVbUxYnWDQa1U0kD i0Sa/hS3inqmK9LUAOkPkOIEDpqMjsuuHaxKJ+OS9Y+znfUkcqYuYpD5/44mFnbR6ovqQ SQsWLW6ADMhbWgSx1Rs9BbatOW3bMf8kitMranu4Gj6r2kmvtiOQ+Glgw3W/4i2GcOtu3 ly5YLUVcE6RuyMnTJOWNOnleJO0gmRmbtDdUZbD+9NQ1tJj4s5i0wp2h7YBhH9h8hKgn5 pUOU5cfasWeTFPgrC2kWek0md+UIQwprmzRBX04pGO7ro8AA7N4yrCVh6OJxSHRSPAw== 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="ZF+M/dy3"; arc=none smtp.remote-ip=209.85.210.169 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (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 4B39D606A320 for ; Tue, 1 Dec 2026 04:56:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4B39D606A320 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=ZF+M/dy3 Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-8d2d4cdb478so1900700b3a.1 for ; Mon, 30 Nov 2026 20:56:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796101012; x=1796705812; darn=vger.kernel.org; h=mime-version:content-transfer-encoding:references:in-reply-to:to :from:subject:cc:message-id:date:content-type:from:to:cc:subject :date:message-id:reply-to:content-type; bh=FGKT9ChZb7WhrEMVqsSmd5I4ABpOcbDEQWGXPM/PImc=; b=ZF+M/dy3tQiw2azZ2HSWNEHhs/bWiWjH7h9l1DK16FndfOJeITq91p8TDNxZCYe1dH Vb60s1S2aq0hXwZtxifJMwOB9C4mnftu6JKtvvDHRLo3Wy3BxsrgYbe9goXqFFPUO/GN 0jVMDiqK+IESkbrYw3+d9fINQAWdC8OiUF8C3viKIeq9qBFpeuTXfFLGp6HBRA+bFtI3 T8iylJx3D/Rh7RuxzP0srrrz4P0N9C85s9U2XIg0WRHjXBO2cUK9rGcz1Depbc8ACoX7 rvqHUsqgqlFwRzmYVIz6zff/YphRuaT7eE6N/ZLOp1pDHtQsf9+8ZthrFp9qH1wkk/bQ 7/lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796101012; x=1796705812; h=mime-version:content-transfer-encoding:references:in-reply-to:to :from:subject:cc:message-id:date:content-type:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=FGKT9ChZb7WhrEMVqsSmd5I4ABpOcbDEQWGXPM/PImc=; b=ezsJ0Hv9dptjB0+zCwRrn/FgWwarONVqZU1XtSrJLnhWCWR3B54PdnU9tVt3SC2Kkm kgZ6ve/agNReSVeRmn4X8t/qxo7GoiVp6bonMfs+1I9+ZvygVKp/7hXGPq0Ih8ODSANW flnwpqEM7L/eEK7J+/5eyhXrxEqcyyfArymAtDDeX2e0qNU4vdX87x8T+CVPNTvdlNuW tQ54DMqcVpbK5oDZjo03NTBh0swbydL2GgZegpYgLXJvYFhYPxOZ+6vtToYqtL8iPIqi /e5QXoP8JnH6kQBPwrnExHfj0wn9nl2vlqu32em7CuVVVNcedmLu678U/P94jwSM7fFZ gGqg== X-Forwarded-Encrypted: i=1; AL+hErHQYnDtU5CWSySrYgA0vaWjh1Ua7Z2RyxMo5LLc5DrHZ/nL1sBpE/RkeotmpKv4C5oMvNaDupfA2RbRxiAi@vger.kernel.org X-Gm-Message-State: APuU4Z+VatNxKZoJs14q8IGGFeuM7enZcfhLaGl616xrM0lulTOfIXH6 +qlS/9YXXs/6boFpHzC3VR6Ndur2XQMDbmJN4A7zFT8k7m+STK0wLBX7 X-Gm-Gg: AZFdTZf3XU+l6duD1zqiJViZMV2AR18uTdG73LQcACe4Xk9/9tnskTzKC1qonIQSrh5 fAIsEdTz9DDkRE9a/ejLDK9lSlVtaFe2sNQeCYhJIuMEqEY0myXdzDb45269wyxhreQ0a6ZY47t yAK3PlOgLHpj89gzbmMBKFjPJU2oasTIOkFRqESQK8D1gahEfm0U4ZPczUZuZNa5M8QYUSDetlw rQra7AH8qBW8ctTX2/L4U/mv324CBgZPG30OIUp0+897NP01k9sre8B035YGPNMnCmvSWBjSKSI xCyMHX4UoyIFUdE4Q/xskfSCwbjo2WXdlpe/0Q5UHfrsDlC6C6PZceKeUvANsTezPt0mG7yz+wW 6ekUndJOCzXNaYrX36dioA7N2j4qpD73lRqay2IGFN0q6Q4xhqYjaT/ySLRK3UJXObp9/TUVm58 0m8+iXcQmA6o0ZFMigQK2/5d/JrlwUL1UOkjDF+qDe7UtOECwWsY1OI7iuCVArY/FAE7bLhdUNw 19nJmQ96TtENdtMgHNrj2+u56anr/K1czh23yEJrel44veDBtvpfoidgU1YD8Xlpu3UgzDcBxp/ jxxE7SnuI3wE3jI/tKoNg0OgSiRKA0DfSeFVn4tU5FOSqmPD1b4elQLQBmSiwa3h65ZZbC8i4Jl RJ1O7tuZDlKqENRafjCvU7P1kAgz4aN793Zo= X-Received: by 2002:a05:6a00:2e12:b0:886:d769:615 with SMTP id d2e1a72fcca58-8c8794b8e3emr32168247b3a.1.1796101011365; Mon, 30 Nov 2026 20:56:51 -0800 (PST) Received: from localhost ([153.61.198.244]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8c87353b333sm18822170b3a.40.2026.11.30.20.56.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Nov 2026 20:56:50 -0800 (PST) Content-Type: text/plain; charset=UTF-8 Date: Tue, 01 Dec 2026 04:56:50 +0000 Message-Id: Cc: , , , , , , , , "Hans Holmberg" , "Anuj Gupta" , "Kanchan Joshi" Subject: Re: [PATCH 0/6] xfs: BPF data placement policy for zoned file systems From: "Alexei Starovoitov" To: "Naohiro Aota" , , , , In-Reply-To: <20261201043452.3866039-1-naohiro.aota@wdc.com> References: <20261201043452.3866039-1-naohiro.aota@wdc.com> Content-Transfer-Encoding: 8bit X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 On Mon, Nov 30, 2026 at 08:34 PM Naohiro Aota wrote: > We can help GC by setting the file's lifetime hint, as zoned XFS > separates file data into zones by the hint. But most applications do > not set the hint, and changing the application code itself is often not > realistic. > > This series adds a struct_ops, fs_dp_ops, whose file_open callback picks > the hint when a file is opened, e.g. based on its name, path, or project > ID. You waited since ALPSS to send this? Sorry, but the whole thing is an overkill if 'hint' is the only goal. Here is a much simpler alternative: struct key { u64 dev; u64 dir; }; struct { __uint(type, BPF_MAP_TYPE_HASH); __uint(max_entries, 1024); __type(key, struct key); __type(value, u64); } hints SEC(".maps"); SEC("lsm/file_open") int BPF_PROG(set_hint, struct file *file) { struct dentry *dentry = file->f_path.dentry; struct key key = { .dev = dentry->d_sb->s_dev, .dir = dentry->d_parent->d_inode->i_ino, }; u64 *hint; if (!(file->f_mode & FMODE_WRITE)) return 0; hint = bpf_map_lookup_elem(&hints, &key); if (hint) bpf_file_set_write_hint(file, *hint); return 0; } and the kernel bit: diff --git a/fs/bpf_fs_kfuncs.c b/fs/bpf_fs_kfuncs.c index 35ccd98..937c278 100644 --- a/fs/bpf_fs_kfuncs.c +++ b/fs/bpf_fs_kfuncs.c @@ -498,6 +498,24 @@ __bpf_kfunc struct inode *bpf_real_data_inode(struct file *file) return d_real_inode(file_dentry(file)); } +/** + * bpf_file_set_write_hint - set the write lifetime hint of a file's inode + * @file: file to set the hint on + * @hint: one of RWH_WRITE_LIFE_* + * + * The in-kernel equivalent of fcntl(F_SET_RW_HINT). + * + * Return: 0 on success, -EINVAL if @hint is not a valid hint. + */ +__bpf_kfunc int bpf_file_set_write_hint(struct file *file, u64 hint) +{ + if (hint >= WRITE_LIFE_HINT_NR) + return -EINVAL; + + WRITE_ONCE(file_inode(file)->i_write_hint, hint); + return 0; +} + __bpf_kfunc_end_defs(); BTF_KFUNCS_START(bpf_fs_kfunc_set_ids) @@ -509,6 +527,7 @@ BTF_ID_FLAGS(func, bpf_get_file_xattr, KF_SLEEPABLE) BTF_ID_FLAGS(func, bpf_set_dentry_xattr, KF_SLEEPABLE) BTF_ID_FLAGS(func, bpf_remove_dentry_xattr, KF_SLEEPABLE) BTF_ID_FLAGS(func, bpf_real_data_inode, KF_SLEEPABLE | KF_RET_NULL) +BTF_ID_FLAGS(func, bpf_file_set_write_hint) BTF_ID_FLAGS(func, bpf_inode_init_xattr) #ifdef CONFIG_NET BTF_ID_FLAGS(func, bpf_sock_read_xattr, KF_RCU) @@ -519,6 +538,7 @@ BTF_KFUNCS_END(bpf_fs_kfunc_set_ids) BTF_SET_START(bpf_fs_kfunc_lsm_only_ids) BTF_ID(func, bpf_set_dentry_xattr) BTF_ID(func, bpf_remove_dentry_xattr) +BTF_ID(func, bpf_file_set_write_hint) BTF_SET_END(bpf_fs_kfunc_lsm_only_ids) BTF_ID_LIST_SINGLE(bpf_inode_init_xattr_ids, func, bpf_inode_init_xattr) pw-bot: cr