From patchwork Tue May 2 23:56:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ackerley Tng X-Patchwork-Id: 13229392 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 EA85DC77B78 for ; Tue, 2 May 2023 23:56:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 815716B0071; Tue, 2 May 2023 19:56:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7C51A6B0072; Tue, 2 May 2023 19:56:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 68CAA6B0074; Tue, 2 May 2023 19:56:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by kanga.kvack.org (Postfix) with ESMTP id 478B16B0071 for ; Tue, 2 May 2023 19:56:06 -0400 (EDT) Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-b9e50081556so3743423276.3 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=ghxnkoOtlAYyQMvV8/3p9K4M0KfcQfiPXNz+Z/cIBsrgrxGGvxorqbaXmS71Te1Rti Lwt+5cmiuF82IwWIiakbaZ9NUJ9aH0SuH4+BNBzI0Xo8gitDGvrmPDvdGsQA9bhqjzeV uovnWCy+bj1R33nOvkMn39Pmpgdh8BVlCLZQpn+le2GKQKH3dFjniznkN3VersjPzZf/ HH6ocx1EoqAhToU98AUw1dc54WUkqXRy5Ibc5umJE7MbfdXbPKxS7aPRNdNhzzl7xmV6 RhxMHAfjgPo9J+FUgZrPAHbirENntGZrP64C02929r3rSIksvgeXgxeVD8c53XHOTsg+ V8Ig== X-Gm-Message-State: AC+VfDw8npMGkPvJRbp2eWcDRyqrH93Gt57Fd/OkOXxrP3UfDfzqJdoG ZzmeFjrMqwIGols6VMyKRGqAvPzm0qb43nfw9g== X-Google-Smtp-Source: ACHHUZ7l2Zyul066g8u0v9VFJHFuMm0nrivTqlRpLBeSkQrDswmmTDc47Xoso9TMDtxKFKBZC3JCAlwv721Bc0rhqQ== 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 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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