From patchwork Sun Jul 23 21:05:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13323343 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 1E975C41513 for ; Sun, 23 Jul 2023 21:06:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AADD56B0074; Sun, 23 Jul 2023 17:05:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A5DA66B0075; Sun, 23 Jul 2023 17:05:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 926026B0078; Sun, 23 Jul 2023 17:05:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 850686B0074 for ; Sun, 23 Jul 2023 17:05:59 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 555D9802FC for ; Sun, 23 Jul 2023 21:05:59 +0000 (UTC) X-FDA: 81044108838.13.DD55AD2 Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) by imf19.hostedemail.com (Postfix) with ESMTP id 99F881A000D for ; Sun, 23 Jul 2023 21:05:57 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=6H+bkOgV; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf19.hostedemail.com: domain of hughd@google.com designates 209.85.128.172 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690146357; 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-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=t847DV14PaTqet7pzsAsrJmRRW43LmacdLCGV0nteSM=; b=aTU0PVSP1cr+/uFm/CVYu3rLFdRjZCAjOHvSyrBbgm2kIWTVuDDHkTAFtjFD/YaOd+c+7P Q9Isfb1Mdx8ijgN6ISEGOxzuBR9V5ZdQ8QM5BznkFUwupIuTdfQncZ7qk4xkFEVhPkXFZH jP3MEk5v9kdtvrY4vJwJYcPd4qRP1SA= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=6H+bkOgV; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf19.hostedemail.com: domain of hughd@google.com designates 209.85.128.172 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690146357; a=rsa-sha256; cv=none; b=So4PI8rB7KFwAcKL7gLsZXVF6xd/tX25NgQm2kXvh87Jkry/ckzK5ktXhGweis0Qz2rmYt Dj5gkRZnddUHR1YhicViChJN2s+iBp88eApUuP/lBSX/K8D3kqK4zA7ukMKiQ5ZcwLdS6W ptMmhDovkXWysdqPO9DdXhzHuHBSFaU= Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-57a551ce7e9so46375727b3.3 for ; Sun, 23 Jul 2023 14:05:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690146356; x=1690751156; h=mime-version:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to; bh=t847DV14PaTqet7pzsAsrJmRRW43LmacdLCGV0nteSM=; b=6H+bkOgVklAa9LvV6mmhZixU4WdBGtni4LwrSdgn1l/L1/Vxdppo+hTh1t/gHkzWts rxQzAotPecacNOASpk1o5a4KVTzU4TUDIWmdZTbdDCkrz2VObwFWw+OwdU139wWPNEQ3 f269kK+66Mt7HngzJIFC8Q03M7FL+7fEW6LPnV/hxcRw8pm57zgcTwqDHukJalAOFldM saBaeQPasr9VRF4NjKr5KyCg0xS4hu+rQ2LHEOIMsghC+EVq6Lqi+lVs8ufWOIllOYyf bjjc88HJfoG6br50QvKXk/yAbXe1DjTasWCxM9ww17GKwln9lkV7Ff+Fq5qJw7BHhj/2 Dr/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690146356; x=1690751156; h=mime-version:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=t847DV14PaTqet7pzsAsrJmRRW43LmacdLCGV0nteSM=; b=J4mwy2zPs/YCHHte1BJe89ff3kLm/Z4WOHo81nuGq4X0aISbExo5pSCBx5RFUNgEmK V/RxmjMtDtPehFxT8XoNaFyU+cVKpek24YOK2FKKDZkZdIBF8qnrKB2TdCmaK7/FRGrJ +DLj8K+3Y0P2NcSdaiARj+lJmEDKfv3RQTF5vE9O74Rxtcbab5fw1PljoCeGkl/jgDeA vpWZTJ3GUPURJju26sEXAFwOR1U8lX3O82MA6yFik6wzr6Ftrr121ZvNDKFxogDNFaLK kmdgD3ZQSW/NRDnsy17c9Ei33dO5zFl0xpGzP6OqWRmsAw/2oKSa2c7vf2zRPD+DILId mHXw== X-Gm-Message-State: ABy/qLaO2bfE36V10TgfERkfaJEU5Os6RVYTrwYE+yFdJBly0q4IpldW 5hEYQVDhDZAeVFL7lPNBx6gYng== X-Google-Smtp-Source: APBJJlFHMVJ/YU/xbiqdDSgLB6BLkRaNWEWGU4gVRJJ45764mDX+eV4vd08NjS967NEIlk5wvbrsRQ== X-Received: by 2002:a81:710a:0:b0:583:a354:f259 with SMTP id m10-20020a81710a000000b00583a354f259mr5288275ywc.3.1690146356658; Sun, 23 Jul 2023 14:05:56 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id w201-20020a8149d2000000b0056974f4019esm86551ywa.6.2023.07.23.14.05.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jul 2023 14:05:56 -0700 (PDT) Date: Sun, 23 Jul 2023 14:05:54 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: David Howells , Jens Axboe , David Hildenbrand , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH mm-hotfixes] shmem: minor fixes to splice-read implementation Message-ID: <32c72c9c-72a8-115f-407d-f0148f368@google.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 99F881A000D X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: ye75myaw1narc4drge6f3r3afsbb79mf X-HE-Tag: 1690146357-981951 X-HE-Meta: U2FsdGVkX1/A4A/wzTB/sSgfQdz8y0+KTkQUu8im24dC8VoczCqBgX8ZoSqT9eVWppLzITHY9OK01idFFYs9LILzr31s07BD0cdIMp/G3Wt4XfsfD+S5c6c+kTEGHnrWfpIuTnyPMfPwWdPEgVn6ApwPwQ72gExTAhzclK0dm7KnPv2WGtDmnr0OqRaq7o1U/1ET5azNUOJBfvlff0mC/acynRw/do/DayhZY3lvKtMptCmOsltp6i0DG59DkOfTKG9BDtQNgP9C5iDazDMfhlcofq8SktK+kFYeS1x9QridLaN2BUdsskTXLlaYKjC2SLNkktDXuJvqji87jBAWnOaSEvMBcvUzeZaB273a7EZvHj18S6WayXG9rI1sDX1OxNQdtfq1X6mDQUgS9onCXXvvxtyyX3FRPIaACM90d/s5LEEDItacbHDRdTuASOduAra7TNJZJN0idOFJPZ6TF707VgulV6an0hh9AFLKcM1U4ZgMJa/fh+/LL6Sx1vS1r566yV6PE+WQ6G2y6yqGQd4gSmSS3NBF2lsgOr3rigBU5oXHldOA5gsW1J6i+ZZoHQ4BDb/+w32t4/jbXgBo8e1JCIZSpF4Pmzzhsdvj/jU0Lk7tdFYs66PgBDJc5ziO1XwDMtjapEcmknDLpp8LP0dExkaIfTgzAZPcm/qNr8UKgXQYGuL89Tz+5RTNp2tZFVZZ6YzsYTWG3yIV49q2dTTXH0BeHM8GLKk14XEFU+3nQjhcp7XQqRJKSgZwa7uJVowQkUDu3FE+uasPSPRHZDxAIFxroH6DHR8BHJFN3p4ZDP2QGwqMueqg4PyANku1+tmtgtaK1zpELowgr/qzG3nz6w9sAOFAC1vGDp+dl1d9NPHtW7Zkht1yPjkKBD0SxJIUrEzTvTTXgEew39g6A5iSceYgR/13vF55Bye3dXT22TZRKD5vgj3mvEM6Ud7TAn8EZYE5z7uQpzc8wzz vBi2SAW0 hCtf02MJCLHDGKTSr4uWiSiNh5PSUujj1rx66woNO4inTEa6NOWGzEXvWsfmT6rngRZY/i7QbOerGpcNJz8ndWsvt6qLMAlE8+BxGcIDhbMjJRz6E5jtoTv7PZ7bElEBxuachhZdz6lXy+V6swL3/88cYTzZqAJ66I5h5oUc2AFzThSeBMNc3LFxpKvt1gh4IxjL/qlv/0iW3tr4f+R0D4n+BzgK4Ck1VzrjCYiaKxeAtTBWu6Hm86GplgbTHrdMME2mEvKD7cLeGY5/nY9/6NQ0Po07Kco8Dh/+0R/dOr7c+yS+0OIqyKERD4d4WJ/VAjy+Vc/xON08FiSlj12FGNRzUz45IeByozfR9eGL/csm0qugqYjbHn5bYhFVBnz9Qe/L8IPIoE/jl/vn4fGpU9x5+pQ== 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: HWPoison: my reading of folio_test_hwpoison() is that it only tests the head page of a large folio, whereas splice_folio_into_pipe() will splice as much of the folio as it can: so for safety we should also check the has_hwpoisoned flag, set if any of the folio's pages are hwpoisoned. (Perhaps that ugliness can be improved at the mm end later.) The call to splice_zeropage_into_pipe() risked overrunning past EOF: ask it for "part" not "len". Fixes: bd194b187115 ("shmem: Implement splice-read") Signed-off-by: Hugh Dickins Reviewed-by: David Howells --- This went into Jens's tree for a while, but got lost when another version of the splice series arrived. The reviewed version did contain two more mods: but its !len check is now done at the upper level, and its *ppos check is unnecessary, given the *ppos check at the start of the loop. mm/shmem.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 2f2e0e618072..f5af4b943e42 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2796,7 +2796,8 @@ static ssize_t shmem_file_splice_read(struct file *in, loff_t *ppos, if (*ppos >= i_size_read(inode)) break; - error = shmem_get_folio(inode, *ppos / PAGE_SIZE, &folio, SGP_READ); + error = shmem_get_folio(inode, *ppos / PAGE_SIZE, &folio, + SGP_READ); if (error) { if (error == -EINVAL) error = 0; @@ -2805,7 +2806,9 @@ static ssize_t shmem_file_splice_read(struct file *in, loff_t *ppos, if (folio) { folio_unlock(folio); - if (folio_test_hwpoison(folio)) { + if (folio_test_hwpoison(folio) || + (folio_test_large(folio) && + folio_test_has_hwpoisoned(folio))) { error = -EIO; break; } @@ -2841,7 +2844,7 @@ static ssize_t shmem_file_splice_read(struct file *in, loff_t *ppos, folio_put(folio); folio = NULL; } else { - n = splice_zeropage_into_pipe(pipe, *ppos, len); + n = splice_zeropage_into_pipe(pipe, *ppos, part); } if (!n)