Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp109499rwr; Tue, 2 May 2023 16:58:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5v+0UPyNPSolCNhwh/G9Wb3VnAyIL2bPygG70AlreciF2bNZWL6OOtCU0YnczT9yxZ3uUr X-Received: by 2002:a05:6a20:8f08:b0:ef:5f:3c15 with SMTP id b8-20020a056a208f0800b000ef005f3c15mr24452497pzk.47.1683071893203; Tue, 02 May 2023 16:58:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683071893; cv=none; d=google.com; s=arc-20160816; b=uiV4mC5/FvWBzD/wFaZNkucnR9lg85q2t63vUvjoq/dW8Jbgm+PRTLgmirPIOS8V+U Vod/OUWcUXhYIiJ0hlSHPu6tQ1nGVDNI40acpv5h+OZNpOpuyFVr5gABJtJIrCqIiBlR 1RmpuxqKEe0xaLFZMZEr9pXgYTkRL0zCstiLArx5CaO5W4cLyyYr/oekEYnTTSiuKJ4d 7F2+o/YzUjYIRxSkHYLjH5/rQPdHpr/LGlTjcyk7Y1Uao3MCvbDowO3TDX7HEM6YWjmC 9wFefQuIgveDY5NiHbthTZfKfgkpKxZoIFqGhOLOeTy56gr0U0+tm+dYA/uubit/xVA1 +axA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=Rm6kQ1RPOx/wKEQB/Wr7FhtY/sYHUQli9SfLyNwvoqI=; b=I8Zr3OhNx4zJgZoh0qw+//ntj/s8VGKRVJJb1cRusihcF45i5LoEJcpAtcZFlbYsOG OZZU722kwkpC0/I2tgC9uynBJXkHCgB9QRh0v+81CX9iH/yUqKoei6AjMwseuR6tPbCs FCktmQseEj8ofgzJ9lQopuLb2jKK4GOSb+Z38xl5JKa/2kESiMCDqkbOwHVOqjeg5YhC u74O5QsUZtgjcoqe/G4S9GsC/4zqW5TA98q9zf4CRUTIGDVt6UjtwpqfuzsS77gsv/sO QJZpN7KMLjwaxt+RQ1c+sCYwdYcQXVkwQskXKkVpXWEw6AUNI7ZS9lNmKz6HDMhQjR5h 8FMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=uld2PwCr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 21-20020a630715000000b00528818a4e17si17573637pgh.32.2023.05.02.16.57.58; Tue, 02 May 2023 16:58:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=uld2PwCr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229936AbjEBX4K (ORCPT + 99 others); Tue, 2 May 2023 19:56:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229556AbjEBX4J (ORCPT ); Tue, 2 May 2023 19:56:09 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 876BA2680 for ; Tue, 2 May 2023 16:56:06 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-b9968fb4a8cso8280751276.0 for ; Tue, 02 May 2023 16:56:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683071765; x=1685663765; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=Rm6kQ1RPOx/wKEQB/Wr7FhtY/sYHUQli9SfLyNwvoqI=; b=uld2PwCrMn+4Zi5vIkxMBtu7gCaRSzRQfkoghLE434QzitskKqtSqPR4P7SDJjYTWT YDaTn99Hu63b5Q3sBMCMhh5S0Dl5gK5yHH6bxjmGPf/XmEUG1oqp19/fO/4zeyF1W+r5 t5AjPjQRwn55Oe+h09+nxyP3KkDlqI0mzpA/difTAhShjIsfmWQGH9A2h60vzrFn6Ybs ozXNeb3UpB5kggiT5mEQhrFgxpNfa37n4ydUSFU0WPewwjhmldheAk5wezK37UBLv/qB a88RjweKfn6lynAg/tWRRIW76S7u9xQvheBv38LXWdv07U5IMEo7aJRQUx28g9h7UAmu wdYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683071765; x=1685663765; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Rm6kQ1RPOx/wKEQB/Wr7FhtY/sYHUQli9SfLyNwvoqI=; b=OutpjOWZMCGkErAuUFK7LIz+7FKKZBokHYagR2Dhmu9khAgQWOuWyopRNNa+NXomzQ AvrRMNDLGmNTo5qsyQgWamWBpynFAfnCc0Q5LldIZM2gN+OFlKtttmIX2JXNYLYOEDQO I4ji0OTIkPCnGUpVk/J6kEznngIquCnnVKvlNPU5wlGCbuLXFM+slDF7nD/LbE45SYEy Nvt8Kv1kYkZDWMf2Re9pMf7GDHL/T+cwAm0POhdndik8F51uQdymzFtw/A1pUgbRzAU+ BO7SDnC2hvUTVoeGVWli7raLft9Z/dD58MxQEjAlVnGCmg7H4/gv7EtZqYNm2AsSDI/U CUFA== X-Gm-Message-State: AC+VfDxK47qlqUfy6aZiK6Mn26ijezp0Nq3FlYwmWzSFtJKxxIAdgUrO D5RgIrHO/45ET4WhcBiv7gkYqRikES1fg5qPpw== X-Received: from ackerleytng-ctop.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:13f8]) (user=ackerleytng job=sendgmr) by 2002:a25:3794:0:b0:b9e:6d41:54c4 with SMTP id e142-20020a253794000000b00b9e6d4154c4mr1685511yba.8.1683071765688; Tue, 02 May 2023 16:56:05 -0700 (PDT) Date: Tue, 2 May 2023 23:56:01 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.40.1.495.gc816e09b53d-goog Message-ID: Subject: [PATCH 0/2] Fix fallocate error in hugetlbfs when fallocating again From: Ackerley Tng To: akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, mike.kravetz@oracle.com, muchun.song@linux.dev, willy@infradead.org, sidhartha.kumar@oracle.com, jhubbard@nvidia.com Cc: vannapurve@google.com, erdemaktas@google.com, Ackerley Tng Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When fallocate() is used twice on the same offset, it should succeed and return 0 to userspace. The second fallocate() in test_multiple_fallocates() in the following code will return -EEXIST for hugetlbfs, but not tmpfs/shmem. #define _GNU_SOURCE #include #include #include #include #include #include void test_multiple_fallocates(unsigned int flags) { int fd = memfd_create("foo", flags); if (fallocate(fd, 0, 0, 0x1000)) printf("error with fallocate %m\n"); if (fallocate(fd, 0, 0, 0x1000)) printf("error with second fallocate %m\n"); } int main(void) { printf("Testing tmpfs:\n"); test_multiple_fallocates(0); printf("Testing hugetlbfs:\n"); test_multiple_fallocates(MFD_HUGETLB | MFD_HUGE_2MB); } This patch series replaces page_cache_next_miss(), used to determine a page cache hit, with a more direct filemap_has_folio() (a new function). I hope that this is also the desired refactoring as mentioned in [1]. [1] https://lore.kernel.org/all/Y8oqEOICcNV762IA@casper.infradead.org/ --- Ackerley Tng (2): mm: filemap: Add filemap_has_folio function fs: hugetlbfs: Fix logic to skip allocation on hit in page cache fs/hugetlbfs/inode.c | 6 +----- include/linux/pagemap.h | 1 + mm/filemap.c | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 5 deletions(-) -- 2.40.1.495.gc816e09b53d-goog