From patchwork Wed Sep 4 20:28:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13791369 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5863FCD4F26 for ; Wed, 4 Sep 2024 20:29:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E1BAF6B017E; Wed, 4 Sep 2024 16:29:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DA4556B0181; Wed, 4 Sep 2024 16:29:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BF5606B0180; Wed, 4 Sep 2024 16:29:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 94AE86B017E for ; Wed, 4 Sep 2024 16:29:42 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4B41A1404D9 for ; Wed, 4 Sep 2024 20:29:42 +0000 (UTC) X-FDA: 82528196604.15.624947F Received: from mail-qv1-f52.google.com (mail-qv1-f52.google.com [209.85.219.52]) by imf14.hostedemail.com (Postfix) with ESMTP id 7CCD2100006 for ; Wed, 4 Sep 2024 20:29:40 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=toxicpanda-com.20230601.gappssmtp.com header.s=20230601 header.b=hoWdDa4W; dmarc=none; spf=none (imf14.hostedemail.com: domain of josef@toxicpanda.com has no SPF policy when checking 209.85.219.52) smtp.mailfrom=josef@toxicpanda.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725481673; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=RWEHhx5O7UFZKYepru/YJGo3B9Ht5vMlNzII31DWFDk=; b=wMKmUHdN6dgpO/K3UY586CdoI1G+sdAm2p7R/4vKDpIYvLxrLz+ja5MtxG8FbsTXCVUSOe CgIRhdmmsxZUo32QYsXhLFSgWmZTrAYJbCZQ5Mb8QFd6SSv9tt8b6Eh3cVkh5k3T6WjXqR C1L5x0wH1Nu0nejDuP2XCysXf5jppAU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725481673; a=rsa-sha256; cv=none; b=r/o9aIekREpSuDEPDiU98FNEw99Or98gc2S303ru7z9l168ZHgokwsLChpTxhuJKH1GMZe NlGgpJfM87rYmdVaNjdgJ7lAhGsxWfO9tx3/BoK2Va6kDvHDe6XscSrJ1utTXmaJeQnPoU VDHPlCnJ2PQm/KiyvI3wHOcLAQ7uoAU= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=toxicpanda-com.20230601.gappssmtp.com header.s=20230601 header.b=hoWdDa4W; dmarc=none; spf=none (imf14.hostedemail.com: domain of josef@toxicpanda.com has no SPF policy when checking 209.85.219.52) smtp.mailfrom=josef@toxicpanda.com Received: by mail-qv1-f52.google.com with SMTP id 6a1803df08f44-6c35334dfb1so182316d6.0 for ; Wed, 04 Sep 2024 13:29:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20230601.gappssmtp.com; s=20230601; t=1725481779; x=1726086579; darn=kvack.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; bh=RWEHhx5O7UFZKYepru/YJGo3B9Ht5vMlNzII31DWFDk=; b=hoWdDa4WrjHpC4BwALc8muGJquCp8OCrlVeWrDNZiHkrn/yjaD1BQ9f5SQ845pFx7j PLsmFNGdI7l06I75lAZC0aDfzPEtuDCJBwtYJtUG42OJ3xCXlJ+8oXZXnyDHCHyUDJSX 2oTWpKW0HOi2npyW1e1kxwauatVcPhsN5rMh6hSpBptRJFY5bKoF04qQE7sHsufRrzEJ s64k9K5S+JG0Qr6eI0LuRkh45pEjRAs8A7NlibsvUfP0XSXlSeI679cja5+E8qtKvdY2 GolmenIf2aFNJ7+fd2qMqbgUxD+XiSwf79vvpCFprz0qIQ9B4iaHoymavUOGtXUz/NPs zV4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725481779; x=1726086579; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RWEHhx5O7UFZKYepru/YJGo3B9Ht5vMlNzII31DWFDk=; b=u/TWTVhWhb8KAht3y3PpG2E3VAJo/1gcvnxyCbgioywchrFSTAbSw6OYVsXTx65/QJ FblpZjHpjK01h542eNh2UCcuGe3nMbvoPhZkPXwVa+VsW5Nf0j9iL/BsxWR3hGoMukLe h2msqiSjsymmJkb6/3eO9Y02tJnyo1pqvhaVVpC5SDY2cxaVKmebitUEQkZJr6o4/ZBF lS6V6DmxHugdWNVkTEojFtsRdRl6zHMjTRiDa217s91tB28kYyW/bk77sX3blk8Wfyq9 9yQW5mGVmN0Zom+xA2B7Xfg/LEVcd8/Y2Ce26Xdd5pSJYAmNoFRQ4K1hg3IR2ZEu5Ztu 6Twg== X-Forwarded-Encrypted: i=1; AJvYcCUJvUoIJOTP510wDTo11tTzCdlcwcknBRZxJOeYBFj93H119/V93VBUKhn+HX5TUCXyL0wtUL1tEw==@kvack.org X-Gm-Message-State: AOJu0Yz44dQRzyE/SiLX38sTGZycHL8WOIV6THQ4scjfZjyyXtwTfGqj +GxWVNF3Ab9l4Y6u5DWEFZo+9yBQIZOcRYeqO16ZrIiGmG5VxkkijMBS5Ti25M4= X-Google-Smtp-Source: AGHT+IGNwdiKO4Frv0IpCUzBFB05rGHrErtdGiSxtnVsPoIgc9Az5OOPtCc2jc4JjLzRxF9YRhdyFw== X-Received: by 2002:a05:6214:498b:b0:6c3:5c0e:2bbd with SMTP id 6a1803df08f44-6c35c0e3262mr134228936d6.50.1725481779673; Wed, 04 Sep 2024 13:29:39 -0700 (PDT) Received: from localhost (syn-076-182-020-124.res.spectrum.com. [76.182.20.124]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6c52041874asm1535256d6.113.2024.09.04.13.29.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 13:29:39 -0700 (PDT) From: Josef Bacik To: kernel-team@fb.com, linux-fsdevel@vger.kernel.org, jack@suse.cz, amir73il@gmail.com, brauner@kernel.org, linux-xfs@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-mm@kvack.org Cc: Kent Overstreet Subject: [PATCH v5 15/18] bcachefs: add pre-content fsnotify hook to fault Date: Wed, 4 Sep 2024 16:28:05 -0400 Message-ID: <89d4bd31a6faa634b9de4cb486498601f042bd7b.1725481503.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 7CCD2100006 X-Stat-Signature: kz4f867edr8nur8ywfu5a1u5t84g7he5 X-Rspam-User: X-HE-Tag: 1725481780-742578 X-HE-Meta: U2FsdGVkX19lbTvTAVJPaKT2ANjB4E+UqI9t4sQaScqvSWYekDRFosU9cbtzU2+wnCy32BuJN+b/IaDaGFRazJ5Uz4NrihTCPO69tnd1OqCOQX9wyEnSZafO95aKkOur1Dswv2YZ5+wQRmhf3ldXaV0rI2j3tBR880oLwuPQaJIVLOhLd97pAEHHHjxl4FKbjcUfcy1Sf0GQtmHhR0PabBw2lt+1l3N5ZQLj0jX5F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N5cxRa5A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.004546, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: bcachefs has its own locking around filemap_fault, so we have to make sure we do the fsnotify hook before the locking. Add the check to emit the event before the locking and return VM_FAULT_RETRY to retrigger the fault once the event has been emitted. Acked-by: Kent Overstreet Signed-off-by: Josef Bacik --- fs/bcachefs/fs-io-pagecache.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/bcachefs/fs-io-pagecache.c b/fs/bcachefs/fs-io-pagecache.c index a9cc5cad9cc9..ce7968e4fd2f 100644 --- a/fs/bcachefs/fs-io-pagecache.c +++ b/fs/bcachefs/fs-io-pagecache.c @@ -570,6 +570,10 @@ vm_fault_t bch2_page_fault(struct vm_fault *vmf) if (fdm == mapping) return VM_FAULT_SIGBUS; + ret = filemap_fsnotify_fault(vmf); + if (unlikely(ret)) + return ret; + /* Lock ordering: */ if (fdm > mapping) { struct bch_inode_info *fdm_host = to_bch_ei(fdm->host);