From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.170 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796101013; b=4negNf0otENcH4vvZNLILA8g4oKcclL+A02AIX4Tq56lQWboBpPEKhsCX5bpTnJo2ZUj fGtUi9TKSrRF+/A+RN4BKaDdPSOIpX53OBp+SiefWlR69C1qa7i4iSkGsRXDdEq4uAdbK S3xNdFQ0vkxWLwRCW7uzqvYCzWTetMPsavkitDYEG0bVcLnqxgR7UgjJwqASZwh90Fmvj ma7uzZMy+OSufgOEODSCSc6zm/VN8v7cuPEBy/8mR4lNiYMzqjk4SMvdq88tcBQE5zPQJ 84CKfq/XGQT4ekm///a3WCMwRx7VeIeKBLCbuwUsxjVuFLo4NcUsShKLzmvSMDpvh+w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796101013; 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=cJf1S3g1Fgba6qDAd10NphG44XT50ZhdbD07TAoy7yf9uvBDxsXVecsbjww/41kR/Rqw im6ca32/gt6IPpzkVeLk4V3JyvYH+D3xaWKc5yyJKowyP4n5wqum0eXVrrT/U1CGom4ng eqvTDeBaahU+sXu6I4zu5fnJtQ9CFl3jZcYTpl0ln2H1Ffqr2Xo+/2v4jmu2jLSsT6kwV 2e7E6hnXiiZxbskXvRSAAiKx4WQQT303Gj1ojibkPLaHo3Rn0nTAJrmvxMrR6ZLAYH2zj afaeAEBcKFMA8c5tk317rdmyrag7v46/JPs2wAAGPYmDp96Dr8DCWgltSGYfRGZQwtg== 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.170 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (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 5AB6C606A325 for ; Tue, 1 Dec 2026 04:56:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5AB6C606A325 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-f170.google.com with SMTP id d2e1a72fcca58-8b58d6f67a5so5581855b3a.2 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=ZT30AjavGcx3MN2AqUxqhGjTfuBm4PWqJIrdhjhiUZ8Ql9naVFHeSKIfAhcBFzwlNp tTw0y9r4baldna520EsYsaIeSuHZzjAZuS3JaWyRnSkxRj9+MKl3P3OYlof1UGFQ9B9v dJBw/o0bKlUDKp8TVlWTF1+9z6LP6lMZFFarXgy9PSgEucC7NHmE7pdu26Y2MWR24k77 FTuJQZX9/uo0LLqtu9R73ntGoiOEjv2qUofLEkkMaWRDGEgLve7EK+jeeZtxI9YB17Bg HshRVkSzUYwSvP+RBM7bz3TcuWx8jPxp0NzHxFP0flshGycOBCyKyUx+twJkiukpZwqy BPRg== X-Forwarded-Encrypted: i=1; AL+hErEhan1e7UJ81xvQ2dySh3qnqCiXfwt08fyk/1DUtsudHNDWQwa90OsyfNobrl8wC/0HnTxDVFP3I05viwk=@vger.kernel.org X-Gm-Message-State: APuU4Z984UGax+PhfEoDWNX86uf1L52Uc9Y+w3XCv8zY9fPAW2jggHDw g7h/feanDxng5ZE65Vx6BARITu9HNVPmyyh7f5FczN20LRD+jQdiup24 X-Gm-Gg: AZFdTZfHlfmdxi6B9j8OL+JkCEX3m6nIVyTJybGljXE2qAsCPzevHT15EdBuU92F5fN xQuwCeRrzUf5FO79ZZv+FkXBp2T3+aaww30kwKdO4FR5scHiDk3ZiKLBm36u+9KfjCzfLA4iAvK gKoLTCmsxBLTh4cOmWNLKfKYkmGAH1YWP3ZqwaAQX7riYRpQfHEQHx7aMD94NuoTPRDm4fNRofw DZlufi8QH1Z/91gfRq7b2mHB7diE9s7IUp1qNvRBeqJ0UFc57PPINX1pidTZhpfxNykWmLWnQOW LAyK+ZIl+zxUBVI1kjOLaisX5KIu9Q4u6jyZV9BchG5/E6K5h6+xdge4RSVvoFjse/bUvAA6869 bh/qADWVI4j9pZ02Gaji6osc2TZvslSatBtnnYd7s8XHm1MofvePtA+q2VVMgLFPXRzl3FzN4Qj BH//a2a4qZbCo5O/w1raj9sSx6MSj8JOAQclZqhCaWLHHM5YpMjkJiRBxZN08s5eoTs+1qAW23b MzLqUlFUTau6rBcoQEUdRahWCZJbZTppjZWVuUlaf3WPKoDyVWOZKRrc4oSFwH7DG3KGg7hxOai ELOyh0vG0aN5k4Ql9iITfmmvVvZE+g5NC85NYaBxNvEKtZ+94HE5KlC6zp9jQ8rky46Q9Jy7wgB 0bvEDwIQzzyqU5A6uGNCOcrh6l9h5IrrsQkc= 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-kernel@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