From patchwork Wed May 31 11:50:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13262038 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 90EC9C77B73 for ; Wed, 31 May 2023 11:50:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 33B416B007B; Wed, 31 May 2023 07:50:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2EB086B007E; Wed, 31 May 2023 07:50:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B3B96B0089; Wed, 31 May 2023 07:50:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 0C92C6B007B for ; Wed, 31 May 2023 07:50:57 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id DBE531C7380 for ; Wed, 31 May 2023 11:50:56 +0000 (UTC) X-FDA: 80850383712.27.A122F22 Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by imf06.hostedemail.com (Postfix) with ESMTP id E93B0180005 for ; Wed, 31 May 2023 11:50:53 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=qoCKNhtG; spf=pass (imf06.hostedemail.com: domain of "prvs=508ef2a02=johannes.thumshirn@wdc.com" designates 216.71.154.42 as permitted sender) smtp.mailfrom="prvs=508ef2a02=johannes.thumshirn@wdc.com"; dmarc=pass (policy=quarantine) header.from=wdc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685533854; 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:references:dkim-signature; bh=YluZ+/Xi9x1Fgj+DRU5BLDV3iMORhYvEbJhB/fZ3bis=; b=SiO/xpJnGNv24KKua18FY02SiCbt4i+5bNkB1Bk6QgDfCxKxUuxci1JiA4YF3JJJWWVQyn JpNqQ4r35QbTVc41vYI5sJUfvwQXV0zUz86CtzlndeE51JYPyN0Vdsv+zS4dW40/0KikZF fuLQ1Rx03KaJcNIvT+crWYAMyQbH5yk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685533854; a=rsa-sha256; cv=none; b=kiMjOov/lmKoIJyLRfU17w2KD5/8P4xe3qF2sLWjnYhfmyN3QEQ4N6OITv19f5JfKN1p1Q lUA8a+wgivranrUIv2/sOJXLocLHYvxyJsWNaIOSTq7luM1x6P8oXTRmoE6aBuzfiSdF0d GoSb4Yq7rNNUysz316Vji+BIrs7tf3E= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=qoCKNhtG; spf=pass (imf06.hostedemail.com: domain of "prvs=508ef2a02=johannes.thumshirn@wdc.com" designates 216.71.154.42 as permitted sender) smtp.mailfrom="prvs=508ef2a02=johannes.thumshirn@wdc.com"; dmarc=pass (policy=quarantine) header.from=wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1685533853; x=1717069853; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=XppOqav2UUYGSjNlhAvtpVVy7ou24D/pviKHTMytfKU=; b=qoCKNhtGL28Awet66nKYqUTffSVuB5s4zRnbOvalc+m8GjANYJmrji97 2zi/2XVkMJTUOdiXummsF/DnVeB7hV0ev+/4Nf7FyRPSnCHJAwcxT7r3X Rd44ZUfSQT66h0/Zbh8phHYsjeS+F4cR9++XI6ZXv0KVQkNeXAI2sTnXT 6eI+9Q/WI416m5V0jkXJkJYUvp5HKR1JvJ7bJD/Vy8pX0o3ABI7ZG4ORb E1QwKHS/fDeFldd4JdJhGCuzt0Q0eQCQnvJRXC/iGu9f+lmTkhpRBFGOy g23ndKXkYNzGIhU49zYdSnMQw9Llw1fUk7lrY4MEsVPAGFheLl1UFncpR w==; X-IronPort-AV: E=Sophos;i="6.00,207,1681142400"; d="scan'208";a="230207383" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 31 May 2023 19:50:52 +0800 IronPort-SDR: Iyhsf9glUtrTMkXL57mIIKeiDCS5+HRkXinFIPzORfCOVuYS/VTNGsKUkUniDwmAcGcydC8D97 3au7YL9Hy05VOwWNhqKhqBlix8qGPIn4cnfA1+wzu6eTCKlPYf+cgspo0pgWePjAvFZjEo1wZm DOxmuNjs2QGlR04X20rzZAKLJgFadSH7MJ7e0DBC0a/xTzWqbkqHFWPhnOnVxsuhTBS7nuHSPm /QrXGqCX/kpLopKWqNBwcjRkIm8cn/sZzTq4JQtaYzxxaRZWK63h1USmVv2sG5EOlfwxbNL42C P1Q= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 31 May 2023 04:05:45 -0700 IronPort-SDR: aBaTXHI9fG0yLOBPINz8tPsC3r6YDYfSeFUWj/Rk8jWbMTPrTXRa0vH3bKfIpcAQLPGli7lgPR YLSb9OcFMBlrCkosi2CpTFqsECBkzuv5p5Jrd02pxOPrTfbsnU9RLpQTpyompRRhsaJ47h6uI4 HFFmIaUfh+yjrEGq8krGyD9f3JlGVP2BCq1uoUGxpapj3rkHXsTVQ9vJNkzdRx+/vCDcwtZ89Q 47IpAVAdH8zdPYJjyDmKkai9L/bnaYPqkDkBF4KWaJslks1l4UWdEo5lNDduud2gkMCfqFjV9d oWk= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.6]) by uls-op-cesaip02.wdc.com with ESMTP; 31 May 2023 04:50:50 -0700 From: Johannes Thumshirn To: Jens Axboe Cc: Christoph Hellwig , Hannes Reinecke , Chaitanya Kulkarni , Damien Le Moal , Ming Lei , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, dm-devel@redhat.com, Song Liu , linux-raid@vger.kernel.org, Mike Snitzer , Matthew Wilcox , Dave Kleikamp , jfs-discussion@lists.sourceforge.net, cluster-devel@redhat.com, Bob Peterson , Andreas Gruenbacher , Mikulas Patocka , gouha7@uniontech.com, Johannes Thumshirn Subject: [PATCH v7 00/20] bio: check return values of bio_add_page Date: Wed, 31 May 2023 04:50:23 -0700 Message-Id: X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: E93B0180005 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: mgk6i9zxhbymsa9t11m6b9ntrnekxkfb X-HE-Tag: 1685533853-366959 X-HE-Meta: U2FsdGVkX180mLL259pooaPengycXLSfQWOMALmswlCZ7AvqvbhEKjXqYFR520iICrp4l5gsqLvaadAcbg1oIj9QCoE0qIsOfeV5kYDjH9cfSuLoI7oO6+scmkQ0JH6LH1Blta5jL7f2w3aOyR5kSmplmJAL72xMY9+dQxC1VUF6mAXi4XJ5PbKv2kNO9S4zVJ8CQjMZFJoJvWdtjRgwy7xIKGWiHAsmJ+S2eHii0yRFcQiDmaWhQamuuUVrqu8xq7JNMYmicSs50IKY+NjJgZsq27pHc2M0RR8pfAjOQYLGsIC9g56IN5c0JPS/40daQrx0ibnES+N6zTlfgUQ2bViCbbgs2su+YcFs/NCbLN2TPMUaVO70VKK/mZT8eo+eeLNOMgDSfZI/o/PkMDnjyRTCLHqNw7DW93S0LWW5WyhYO+N/HMendO6/hpHSHgX+VngD0wa+O2Zu3aq7LbN1kA4jthOCH2H1fn1kFgyCsnkERtFKHPxS87Abc5XydRwfj5GUNHR6+yAXrQ+Dg9SAChYuE3gnqxCZe/zwVLUfL/NVcJ/xq7tTOYUDFrGfFYrm3+3tU6Z0Qv10f0AuB9IOqj17rtJ8YEfO4HpzhzXSugasGmFSVPk/d0INeRWeI9roCmyxCMwWDV1fKyUf/XFmg7rTQLZEaHn4njOfes+88TElRTHrD4Z3MIJ5uR+286sfK3yPD9I6w/TuLWM+a72ceeoMvjLHCwPx+CRlRBSaj1SfQe1OPP9a0o57FtDF1RZHfnkiq/fnCY0q1omwWsiTuDKkrTVvvKNAWbKcgrm9RRwFgfOvgkqcj37R8hLcOmrvg2I3KJugazkSdL53CT4QilgCLRxoGpfCNUZbI2bf+e0nfiwRhRqOiBiYq/JOdMTmOWOR743FUWwMwJ4vC9SC7RW21WdVLNbR4mUxmJk0Ne+k3gTbEj61dwbqc4Btjbv22nwuEMmchcpDBqRG91/ L3Nstyrt zMPKoq7Ka1cbmAqDY/R+fiC1AvyQnravGxIGYXZ7wN84VcEUfQq/p65P2PM5jCcx6V0FvIt5t2UPi1DJxF/xp7Ch5vf57/SYOyKN/P4Cz/YLVSTWx8KnJFi9XPYpD3S6YAgyDGZoagVOqVtO8O7ATDm1KqW7Fmn67wqfc3yezkFuIgIqKBp0ff3XaKxLqXOdOK519sOJwTjepzWZOB5GrLREMGvtIsakL9dJlwD/ygMP5k/X5l2DxxiU6uE3hJXJ61080MLjYO5DFpZJcZ49CkUgMrq5ujAJpnU8t4g2oouvRO6XlgPOyUgHOKyTw8PI83wRVhI2FpSAqSfTFEtqsnxxEhw== 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: We have two functions for adding a page to a bio, __bio_add_page() which is used to add a single page to a freshly created bio and bio_add_page() which is used to add a page to an existing bio. While __bio_add_page() is expected to succeed, bio_add_page() can fail. This series converts the callers of bio_add_page() which can easily use __bio_add_page() to using it and checks the return of bio_add_page() for callers that don't work on a freshly created bio. Lastly it marks bio_add_page() as __must_check so we don't have to go again and audit all callers. Changes to v6: - Incorporated comments from Mike and Christoph - Collected Reviewed-bys Changes to v5: - Rebased onto latest Linus' master - Removed now superfluous BUG_ON() in fs/buffer.c (Gou) - Removed dead cleanup code in dm-crypt.c (Mikulas) Changes to v4: - Rebased onto latest Linus' master - Dropped already merged patches - Added Sergey's Reviewed-by Changes to v3: - Added __bio_add_folio and use it in iomap (Willy) - Mark bio_add_folio must check (Willy) - s/GFS/GFS2/ (Andreas) Changes to v2: - Removed 'wont fail' comments pointed out by Song Changes to v1: - Removed pointless comment pointed out by Willy - Changed commit messages pointed out by Damien - Colledted Damien's Reviews and Acks Johannes Thumshirn (20): swap: use __bio_add_page to add page to bio drbd: use __bio_add_page to add page to bio dm: dm-zoned: use __bio_add_page for adding single metadata page fs: buffer: use __bio_add_page to add single page to bio md: use __bio_add_page to add single page md: raid5-log: use __bio_add_page to add single page md: raid5: use __bio_add_page to add single page to new bio jfs: logmgr: use __bio_add_page to add single page to bio gfs2: use __bio_add_page for adding single page to bio zonefs: use __bio_add_page for adding single page to bio zram: use __bio_add_page for adding single page to bio floppy: use __bio_add_page for adding single page to bio md: check for failure when adding pages in alloc_behind_master_bio md: raid1: use __bio_add_page for adding single page to bio md: raid1: check if adding pages to resync bio fails dm-crypt: use __bio_add_page to add single page to clone bio block: mark bio_add_page as __must_check block: add bio_add_folio_nofail fs: iomap: use bio_add_folio_nofail where possible block: mark bio_add_folio as __must_check block/bio.c | 8 ++++++++ drivers/block/drbd/drbd_bitmap.c | 4 +--- drivers/block/floppy.c | 2 +- drivers/block/zram/zram_drv.c | 2 +- drivers/md/dm-crypt.c | 3 +-- drivers/md/dm-zoned-metadata.c | 6 +++--- drivers/md/md.c | 4 ++-- drivers/md/raid1-10.c | 11 ++++++----- drivers/md/raid1.c | 7 +++++-- drivers/md/raid10.c | 20 ++++++++++---------- drivers/md/raid5-cache.c | 2 +- drivers/md/raid5-ppl.c | 4 ++-- fs/buffer.c | 3 +-- fs/gfs2/ops_fstype.c | 2 +- fs/iomap/buffered-io.c | 6 +++--- fs/jfs/jfs_logmgr.c | 4 ++-- fs/zonefs/super.c | 2 +- include/linux/bio.h | 8 ++++++-- mm/page_io.c | 8 ++++---- 19 files changed, 59 insertions(+), 47 deletions(-) base-commit: 48b1320a674e1ff5de2fad8606bee38f724594dc