From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796394447; b=HOfzm+BB3WYjH269AE3zckRLS8qj+tI7jrn8FybZNy/wtbrAtwHFLWSd4hwJ16HE8IMV AglOD1O/tQpmBaK6VQQaKRnz/aXk/bBKPzq10U1TMW817IlkX/1rrrNRv4LyyFISnp1lt 9q4JsSjUy4EUj80hkNVTtbEb3aRpXzqT/VqT8wLY43LxBz/NPAd+HeE7LAXaMDTlb7naR +qVRX3SDv+rAsBi+pIiDaYtm/QBRq4+Xbubl5Ngp9Lw9hMljWitiFgd5BvKPp/eGR44IC Z7saZk1ttnrH33XRAXQDDU4REdpQ/0X9e0dzUew7IUySWM6EHs6Xl+Ik+XOjFTJaTHw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796394447; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Sender:Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=ZHNwUt5G1V9cXQnYhODVKxrV3fgAmNZTG6uqCt2JJXE=; b=PNDx/JQYTWSztqtS8X89finBLU0MijqPAy0Uj1QtdSfiC+H108wICvBdgUfyBTBDIIky XwdfAstO+oR8yu5IytQvOa2Ox+L0nDTiZoZAgGELFQsyvhDVvSrvEm/f/2M+nVQcujMvS NPhAEg16QUKjzgW12uGbu93xoTAcPmK/oaFEPbM7MtW12o3gFWe35wtbNZnY73STS3vfM j9+mYYvHKfKpzjheZNIbLMYwOF4iFKBxVF2CSyy30yId59slNXN4/O8MHKdKizsPqXf1n BIjfwvsZ+/kNUiS9vn7jf4p4nKNMsNe5JtWtv9yraaQhBwQ++nISeuSgvQlaPvJcgDg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail header.from=debian.org; 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=gsr65jRy; arc=none smtp.remote-ip=209.85.221.51 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (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 DACAB606A32D for ; Fri, 4 Dec 2026 14:27:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DACAB606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org 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=gsr65jRy Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-4b52fcb410dso1472514f8f.1 for ; Fri, 04 Dec 2026 06:27:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796394445; x=1796999245; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ZHNwUt5G1V9cXQnYhODVKxrV3fgAmNZTG6uqCt2JJXE=; b=gsr65jRyQeybWE6mQboUKVg0MLIy5j0LICQz5pxJAobWcWWbp/cSUY3hEkqPVRTRWM RptlqqHSjREk8h77pXGK1/K8LqTRAB2AuARLimnFJ9bC6ADDdk9fh4YAebkbSmqnuL/Z qbUtc6RDW6oMKovo6rDlssUchq2SL/TPFASsdE20hF9X7J9cHsf9LAFCN7NMB5Z58KFa hjFvbckaFa+ljpK89MVyAySl5f+qppdwBkA/8X0QiPPRoYmEoltn/X2h9A2Pt7kMEsLJ TW/5WOiXYyp9TknoYYi8Lr3W2FP6XgD7PY9QOiTzAuDImas47zkJMMlL+nBtWOL1dMRn bCOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796394445; x=1796999245; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ZHNwUt5G1V9cXQnYhODVKxrV3fgAmNZTG6uqCt2JJXE=; b=mF1cvvctSJ0eSrCcW3DNnI61/PuMTCIDB4Z+2aXQOXSdfbx6r0okzrOY2o5O06U2Ok dJF0/K9r6UkMV8DY+41BDRuQ+FqSQwpjTQ4n5PBHRpXYdr5eAar9+r3CS++MogVzjj1Y fy5wEiW/fLWBxZY9RKC6Av3vRlFFO0uUjjYkTpX18uST28JSblDWpO8pi9Ar2hN0mhhP sfIs8qGgXoiGtpMGQeDxT7G8bhQmIHNjqB+P/8xZLYz1DqwycNjSqAsot+9+Pnbe1Q59 Y7jbohWUcKCFTvRRKPjsQHWombREcqiKkRklmUnoTEX8NHqRSQuAdU4UUDhoPXqy7pHx hI0A== X-Forwarded-Encrypted: i=1; AL+hErFK9S6rQ+d5IVyc7AmRUOhhHJ77DSIhwHgUKw3HzfopHzZsiuhZwzsMTPB6bke/ZnBy7AehPdU=@vger.kernel.org X-Gm-Message-State: APuU4Z9086WVUP9uJJsdZ9A0Jq/j2H5h+rFk3b+Evp5ffQlpxHLtKK+p hRBbq+RNZM7/FP+tnNUFSau5v+L8gv4lYzgCNI9tarf9ZBMWGTTmO2ff X-Gm-Gg: AZFdTZeVQ+4rd5VlksIp20QrjBALctv3kdv9IxJuRtup6Vt10PrvmtldnoyZJpAfN6/ M/2VY2t/bDkO1LDChmSfNCYE0DGf8hkt18H7xhblohOGe1eD0+OppuWUH7uU3evLg6iSZp7461g yuGXSiXUXH7JwZaVGar6OMgn4jprpo2CkWCkbm6P8eaUV/EZHOR/KNp9G6qvQ8aY2Rkn2yXNG5h vbB7m4JzTHuhzO56nriou0tzmKImhGg8Yj2HYVte1sDYbYPh5ZGrPNQLhew4LwX2/z9/crPw5nT 7XrH2JdwVvsKgRaFoBYLijDYiamz3UqmYZ0aGgVp/SVewC8RSa2B72pS/SMJddjTmS4FscG2Pa0 QiBvZ2yU8zmNuYYW6DhJ1JQ0Jc4jQnCHbjoIyw3MflFjboJ7az5vvo4mER2wkiKIvTBRzeCCAUs //9CkDwnbNz0DrcVlpBpOkqT3IGkxOS1Hi2lKvBe+QeFrtBhiVRzFD4Aa8wLuj+cmxGZnJpOEJ4 XarLv9GJf2go5+Tp/sdMvC0L+lZffIQtHJ2SoR8dAOJL3+vnMrWC0ys6e33GzFNyzq6+wfzJVON VXXLKPubFBW9gEYqdr+S0IbQDQOUGfAGcwhd5awXbbFl2Mhbx/wofz7RUDUDkT8W9GIgpAz4bwE KpSLzLREw8w== X-Received: by 2002:a05:600c:4e52:b0:4b4:a551:681a with SMTP id 5b1f17b1804b1-4bbeb8512bemr44579835e9.3.1796394445148; Fri, 04 Dec 2026 06:27:25 -0800 (PST) Received: from eldamar.lan (c-82-192-247-196.customer.ggaweb.ch. [82.192.247.196]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbeb6f0085sm45486035e9.4.2026.12.04.06.27.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 06:27:24 -0800 (PST) Sender: Salvatore Bonaccorso Received: by eldamar.lan (Postfix, from userid 1000) id 04DEBDC04A2; Fri, 04 Dec 2026 15:27:23 +0100 (CET) From: Salvatore Bonaccorso To: Julien Leclerc , Jeff Layton Cc: linux-nfs@vger.kernel.org, 1153524@bugs.debian.org, Chuck Lever , regressions@lists.linux.dev, stable@vger.kernel.org, Benjamin Coddington , Christian Brauner , Salvatore Bonaccorso Subject: [PATCH 1/4] fs: Introduce FOP_ASYNC_LOCK Date: Fri, 4 Dec 2026 15:20:29 +0100 Message-ID: <20261204142703.1100372-2-carnil@debian.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261204142703.1100372-1-carnil@debian.org> References: <20261204142703.1100372-1-carnil@debian.org> X-Mailing-List: stable@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 From: Benjamin Coddington commit 8cf9a01edc216b16b5839eb793ac544d2c97ce97 upstream. Some lock managers (NLM, kNFSD) fastidiously avoid blocking their kernel threads while servicing blocking locks. If a filesystem supports asynchronous lock requests those lock managers can use notifications to quickly inform clients they have acquired a file lock. Historically, only posix_lock_file() was capable of supporting asynchronous locks so the check for support was simply file_operations->lock(), but with recent changes in DLM, both GFS2 and OCFS2 also support asynchronous locks and have started signalling their support with EXPORT_OP_ASYNC_LOCK. We recently noticed that those changes dropped the checks for whether a filesystem simply defaults to posix_lock_file(), so async lock notifications have not been attempted for NLM and NFSv4.1+ for most filesystems. While trying to fix this it has become clear that testing both the export flag combined with testing ->lock() creates quite a layering mess. It seems appropriate to signal support with a fop_flag. Add FOP_ASYNC_LOCK so that filesystems with ->lock() can signal their capability to handle lock requests asynchronously. Add a helper for lock managers to properly test that support. Signed-off-by: Benjamin Coddington Link: https://lore.kernel.org/r/3330d5a324abe2ce9c1dafe89cacdc6db41945d1.1726083391.git.bcodding@redhat.com Reviewed-by: Jeff Layton Signed-off-by: Christian Brauner [Salvatore Bonaccorso: Resolve conflict in include/linux/fs.h. v6.12 already defines FOP_UNSIGNED_OFFSET as bit 5, so FOP_ASYNC_LOCK goes in as (1 << 6), its value in v6.13.] Signed-off-by: Salvatore Bonaccorso --- include/linux/filelock.h | 5 +++++ include/linux/fs.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/include/linux/filelock.h b/include/linux/filelock.h index bb44224c6676..c412ded9171e 100644 --- a/include/linux/filelock.h +++ b/include/linux/filelock.h @@ -180,6 +180,11 @@ static inline void locks_wake_up(struct file_lock *fl) wake_up(&fl->c.flc_wait); } +static inline bool locks_can_async_lock(const struct file_operations *fops) +{ + return !fops->lock || fops->fop_flags & FOP_ASYNC_LOCK; +} + /* fs/locks.c */ void locks_free_lock_context(struct inode *inode); void locks_free_lock(struct file_lock *fl); diff --git a/include/linux/fs.h b/include/linux/fs.h index fc63611ac3c6..57a9f2e1e23c 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2177,6 +2177,8 @@ struct file_operations { #define FOP_HUGE_PAGES ((__force fop_flags_t)(1 << 4)) /* Treat loff_t as unsigned (e.g., /dev/mem) */ #define FOP_UNSIGNED_OFFSET ((__force fop_flags_t)(1 << 5)) +/* Supports asynchronous lock callbacks */ +#define FOP_ASYNC_LOCK ((__force fop_flags_t)(1 << 6)) /* Wrap a directory iterator that needs exclusive inode access */ int wrap_directory_iterator(struct file *, struct dir_context *, -- 2.55.0