From nobody Wed Feb 11 23:44:44 2026 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (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 A35C654F96 for ; Fri, 29 Mar 2024 01:54:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711677288; cv=none; b=drDvs+oidX8/jinUfIzVx7Dd+bG+ZQRwNNHQbr4K1j2Md3mmXLYE7WqeQHWgJOmWoRqk3P2F6mqaq8UAHyCXNxjMGahfKhCThVBRu4avx/8HP67DZT47d+5UM1lCmLuOYWzHWBZVUXlF4Q9N3FKz2hmTQObfUw4Ke91//cVJXOw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711677288; c=relaxed/simple; bh=bBfAJi/bJf2nD+gd3YqaNeaEuDQ3ztMPp8XYXKoJ52g=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=A52V1W4d6KmOs4RzlehVHw3rGoIgAxd7ey+2wOEc32XA+Jqi4EUmnEtkhsnvXq95R0Ks+r9SAfVFqKyAVkYvdxvUELnRPidQkZUB+JjHJAJmujadD++jgN0jU7eoMA8QDBNGe7lyZz4VfPrQfutGQ2YPbkhHH/pV+AV5O34rQ70= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--drosen.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=wHJkKVjR; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--drosen.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="wHJkKVjR" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc693399655so2763606276.1 for ; Thu, 28 Mar 2024 18:54:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1711677286; x=1712282086; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=RHfrMplbbUkEBek0oxfkmQFW+uLxDMPloBNof976q78=; b=wHJkKVjRMmLu3l+quU/T1dkRy2eN9n0/f3raXxrUmdxkEBl+F5MjZr/xg38d4MvCqS Zs9QTc8jOGKXFRO4lO1MZBy7urTGovN9UqoSDGIj4vkCU6yKuKVfKoMFe23nx7gPicwU qTndnx7gWcpxrRQE3Bd68SISe31PeCm+I1cUHij18e1P5B9gpTPn5zi1CCK0q6EzeBqm Tc6Q/fcJVszPKaxFXH52l8WwjB31mbv0hsR5M7dzl9cGBNJFiLE8X9zQbPjt7yi13eTb +hYrgs/m/hkK3FRhKnopDAs5EHcEA4vG5Ef4vtT6QkBqDzMPAh39LsuLInkr63qWHXkW YRvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711677286; x=1712282086; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=RHfrMplbbUkEBek0oxfkmQFW+uLxDMPloBNof976q78=; b=VcNXbrR+2J2GbaxJ7YxZBbe9I+KpuWR7qnwoODC34zDlG4gGIiudgqykTRYGC5uxbA flVVO0IQA5ph2Wpo3jiZvpcyIOtUttnoCN5kdb+Ib3Hqqv4VQlJNW/n28g8HI4HyVkzx hCge/v45AmYt6D80HnsuCwt/eCDgqlIajCJ3fj/zKtfIqc+OevbBa9D/ARLB5X0TSqIJ wCAobsIPwvvSSRDrBarmsayHH+yCIunTwEgOIX2LbzIQI3HkNVeb8JWykHNfqZ8vpGm7 itsKoBEOm5WyK9dzGprt4jHndLP76gaLp74euenGMtyPynWlD8r5CDJxce4P9J+bhw9+ xQjg== X-Forwarded-Encrypted: i=1; AJvYcCVhg1iWGQxG2OGCJ57o71d3G3ZkXwVMd5PUynFYdFs/9TATlqfO6qcjRwtl8xmLkvnSHIoa+kcdFrLDPkuLpkXr4rXMI2jVCeYo4JUh X-Gm-Message-State: AOJu0YyQ5NeLtHPlLUbBO1DmmB0V/iHAWbuqWVerWQf0I+RI2kUubUHn hC5FOqy50kzYP3yxH/CDAB/d7/5gnbzHdHACZatfRtG+Dey7NvXDSq7htOgR8AYGcS782/UfHtF rWw== X-Google-Smtp-Source: AGHT+IFbnUa67u4V59nNCnGnTBVkSthpFf64uvZOHCdvmkQja1eGLLGkihEUhtkYy01teYap9rh/yjJgyyU= X-Received: from drosen.mtv.corp.google.com ([2620:15c:211:201:fcce:d6ab:804c:b94b]) (user=drosen job=sendgmr) by 2002:a05:6902:120a:b0:dda:c59c:3953 with SMTP id s10-20020a056902120a00b00ddac59c3953mr322226ybu.0.1711677285863; Thu, 28 Mar 2024 18:54:45 -0700 (PDT) Date: Thu, 28 Mar 2024 18:53:36 -0700 In-Reply-To: <20240329015351.624249-1-drosen@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240329015351.624249-1-drosen@google.com> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog Message-ID: <20240329015351.624249-22-drosen@google.com> Subject: [RFC PATCH v4 21/36] fuse-bpf: Add partial flock support From: Daniel Rosenberg To: Miklos Szeredi , bpf@vger.kernel.org, Alexei Starovoitov Cc: Amir Goldstein , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-unionfs@vger.kernel.org, Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Eduard Zingerman , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Jonathan Corbet , Joanne Koong , Mykola Lysenko , Christian Brauner , kernel-team@android.com, Daniel Rosenberg Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This adds passthrough support for flock on fuse-bpf files. It does not give any control via a bpf filter. The flock will act as though it was taken on the lower file. see fuse_test -t32 (flock_test) Signed-off-by: Daniel Rosenberg --- fs/fuse/backing.c | 15 +++++++++++++++ fs/fuse/file.c | 9 +++++++-- fs/fuse/fuse_i.h | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/fs/fuse/backing.c b/fs/fuse/backing.c index f18aee297335..b2df2469c29c 100644 --- a/fs/fuse/backing.c +++ b/fs/fuse/backing.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -1586,6 +1587,20 @@ int fuse_bpf_file_write_iter(ssize_t *out, struct in= ode *inode, struct kiocb *io iocb, from); } =20 +int fuse_file_flock_backing(struct file *file, int cmd, struct file_lock *= fl) +{ + struct fuse_file *ff =3D file->private_data; + struct file *backing_file =3D ff->backing_file; + int error; + + fl->fl_file =3D backing_file; + if (backing_file->f_op->flock) + error =3D backing_file->f_op->flock(backing_file, cmd, fl); + else + error =3D locks_lock_file_wait(backing_file, fl); + return error; +} + ssize_t fuse_backing_mmap(struct file *file, struct vm_area_struct *vma) { int ret; diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 46de67810f03..255eb59d04f8 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -2676,13 +2676,18 @@ static int fuse_file_flock(struct file *file, int c= md, struct file_lock *fl) { struct inode *inode =3D file_inode(file); struct fuse_conn *fc =3D get_fuse_conn(inode); + struct fuse_file *ff =3D file->private_data; int err; =20 +#ifdef CONFIG_FUSE_BPF + /* TODO - this is simply passthrough, not a proper BPF filter */ + if (ff->backing_file) + return fuse_file_flock_backing(file, cmd, fl); +#endif + if (fc->no_flock) { err =3D locks_lock_file_wait(file, fl); } else { - struct fuse_file *ff =3D file->private_data; - /* emulate flock with POSIX locks */ ff->flock =3D true; err =3D fuse_setlk(file, fl, 1); diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 8ae6ad967f95..e69f83616909 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -1651,6 +1651,7 @@ static inline int fuse_bpf_access(int *out, struct in= ode *inode, int mask) =20 #endif // CONFIG_FUSE_BPF =20 +int fuse_file_flock_backing(struct file *file, int cmd, struct file_lock *= fl); ssize_t fuse_backing_mmap(struct file *file, struct vm_area_struct *vma); =20 int fuse_handle_backing(struct fuse_bpf_entry *fbe, struct path *backing_p= ath); --=20 2.44.0.478.gd926399ef9-goog