From patchwork Thu Apr 20 10:04:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13218301 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 6FA69C77B78 for ; Thu, 20 Apr 2023 10:05:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D1CF6900004; Thu, 20 Apr 2023 06:05:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CCCC1900002; Thu, 20 Apr 2023 06:05:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B94D3900004; Thu, 20 Apr 2023 06:05:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id AAF1F900002 for ; Thu, 20 Apr 2023 06:05:53 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 59C6FAC0C5 for ; Thu, 20 Apr 2023 10:05:53 +0000 (UTC) X-FDA: 80701338186.18.6609FA3 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by imf23.hostedemail.com (Postfix) with ESMTP id 8A97C140026 for ; Thu, 20 Apr 2023 10:05:51 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of morbidrsa@gmail.com designates 209.85.128.54 as permitted sender) smtp.mailfrom=morbidrsa@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681985151; 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; bh=ZcXCJ3SJOteyet1IXFZTQ3OoqtJ2euWeW1pB3mgV2W4=; b=ajMfEKFmN7bdbsIKzR0EXMbrDKgs5TxVDVOtBbG4JkU1KnPvMiSjKEFgjImq4nqld6yGAX rOLOR2diaqsXLg4QKhBFa9uvarYJjboHZELzzMRIUoSE1cznLHtxOZupVipwl9N+i3uZsU mwr56Jr5rLvPpX1oPBpjZ0f4sNtE2H8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681985151; a=rsa-sha256; cv=none; b=DPZBIZF6nbCI7YchjaTHw1YUR6HUNqhmmFSprSbMUOYa5e1sUla8/1AWSl5+/BREXWUCsd JhrgzGW5dQbJRL4Dfdurs4np/rjbhkqAJiS1twVM4nLoLbLNTCFUhbIL122TsIh5HcMUu6 xwM//jCe9L4ZCcSC5ZjHPNiJlNgm6Rw= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of morbidrsa@gmail.com designates 209.85.128.54 as permitted sender) smtp.mailfrom=morbidrsa@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none) Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-3f086770a50so3647355e9.2 for ; Thu, 20 Apr 2023 03:05:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681985150; x=1684577150; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ZcXCJ3SJOteyet1IXFZTQ3OoqtJ2euWeW1pB3mgV2W4=; b=iMEJTh640x39INtuy0c9JbYtLM01GpUzb1voAZy7ZAi+OugdYul1L1G+QYr8THnr9K UXV06C4WPTeMqskBvUD48I8EI+6P5Z5iL/FvcHhhSTkyKmZtv1T0eMc5uBvYedWCU9Tv 0RUTWfKjIbELpNjl/8QbKq/U0BjXhjq8wH2CYcUGsT3X3g+s6XZzBvb1sdpnDWVrolNM 8U9ANSMHDMamwey362dtBkR+g4m7fECUBBb02D4hQUMArpk/WsaIX/DdO2RALeQBTkoj X6Y8oVHX+zbqjytQv8Dv4Gst3uOht/Wwqsw6OEs3M5DgpX4aD+Afga5WHtS6rjxZYJC6 rYKg== X-Gm-Message-State: AAQBX9dLSjTWBkfn6H4w/+wnYV+u+2aZlIemJXHIOugwVnlDXhn8iU0X RQyYfLFrh88PikqYQNi40xo= X-Google-Smtp-Source: AKy350ZgMStjbiqJTTKXUPdei9S3WxVemsjZICWKQrqIJ34flrxB2Hb2jlcmCp+kqLQGz5LFUepZLA== X-Received: by 2002:a5d:5683:0:b0:2f7:8acb:b823 with SMTP id f3-20020a5d5683000000b002f78acbb823mr707539wrv.56.1681985149859; Thu, 20 Apr 2023 03:05:49 -0700 (PDT) Received: from localhost.localdomain (aftr-62-216-205-208.dynamic.mnet-online.de. [62.216.205.208]) by smtp.googlemail.com with ESMTPSA id l11-20020a5d674b000000b0030276f42f08sm201410wrw.88.2023.04.20.03.05.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Apr 2023 03:05:49 -0700 (PDT) From: Johannes Thumshirn To: axboe@kernel.dk Cc: johannes.thumshirn@wdc.com, agruenba@redhat.com, cluster-devel@redhat.com, damien.lemoal@wdc.com, dm-devel@redhat.com, dsterba@suse.com, hare@suse.de, hch@lst.de, jfs-discussion@lists.sourceforge.net, kch@nvidia.com, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-raid@vger.kernel.org, ming.lei@redhat.com, rpeterso@redhat.com, shaggy@kernel.org, snitzer@kernel.org, song@kernel.org, willy@infradead.org, Johannes Thumshirn Subject: [PATCH v4 00/22] bio: check return values of bio_add_page Date: Thu, 20 Apr 2023 12:04:39 +0200 Message-Id: <20230420100501.32981-1-jth@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 8A97C140026 X-Rspamd-Server: rspam09 X-Stat-Signature: jrqbjyudreqmsro4t6cpy5jqbbxqrhyk X-HE-Tag: 1681985151-644313 X-HE-Meta: U2FsdGVkX19s0yV3+3e2AdVDx8UlaR7fUHr3IpV3QxLk2+mB8Dfp0Pfvk0xzECZNI6nFL0RHvD0+gblLScLpMy1f2wSohBFxTu3QcGEz93H+qNTPnu3y174dXVfepqlElhV6c5tUlRt3xvo+zvq/lyt4YjxYlp7ny1ZFNnmB+DwsnL18Je849qQ7CDg5+WqginNt6ac3Xaslr+5TNTZe1z3mGrUskLELxylsJLSkN7WW3j8e00mCs1At/ogwj0JiJkKzfj3WiPiF5+8axFqc4D6c8qf3eNNd27Cidg/8Ej+R6E7Irf0I0rFQrRKBm3LAZ83A86vDHCZr5VzZN6pIJDm8ZSFUlgYnBXmOKG2WMOBxSMPQS+IHPi006j/4HorcUM9JtFI7vRXrWRyD9jsIpDpbMPsOylP5gckRiB1NzEi/28YBJA4UVbVTnAsNn9bqtF+HPWc3yWURsFLsD70ZLDMQIP0QZVIJS13PtDUv5fiWkUQz9EzC4p6m7wfNv8uYjuUOTaMzHCvAmud967RB5wCfZSLvCEiWHmGFjQ9e326sYEKDs6TQ4mcmXJ5EDPU95AxyFiXIBfFoLwhsyIKRtStBTDuy9ZfhhCLwY8V2QuQISXVShX8Ho75qqY1TMYj1c5GJ978sVpxbLGPmYH5U2oX2hTl183y4CA6RrxEeP+BpMBXbKEZctHW/a6nMFPhEnd/VZmZyOekumjBlYsij641M8BzH+7QPipIUHhsfcCZDrZc+Wo0kOginblwY0UuGhlMUTaAUvsfpL3E72KMn3/Wa0ug1NFyRcvowN3d9CFApQtRBVNRUi9RE+YjSRm9S7becRkyuBFfCbctMMYYYQw8EtoPm1MFtHq7DQNQR0aA/iPlVGAzDLznGpsW5bZPVvhY4DsaKerz/jgpAnZt/g9HSNl/BPWOBvuUogMLUciz6OPDFjMWzFa7WgGhA9E5l3/WRhMI2hOldwWQhkrc 9EdWc/UH Demu8UIOtf7ImKB8rtgzoE1Mc96jKy0cnXSXqT+HL7xPdydUXoY+2Gn/KvFYk4oVLge6+cX09khUfRA+pqHzDcjd1UTtNt6ELIDKBySQ1Coe1vqFJ22VbbUDI2mzDnvSiGRqxKqqY8q7NYUj5NdL9AxqpIBs41NxT6dsxcKK+K0Z8hxFfgRgEI5ukPg3bqJqKO2ACQnjwcfst9tHPa39RIui+i8LtoqSRejdmBb+uRc3yvxl/QU9plTI+pKfV9rtbLBhOmxqZEGR3CPQwgKP5Pf/fQHVMF4OUDDgDLFEGYDRlSQr7G5fZgBDIB+yfzQMYQX9rvWYJdgNkflOiFSgDh15eCDZy5QtS20ghKh4MygTM/zpJzQNCw8mpxkUKSpzwK2yL7YxWOm0jJBGudAO+/jlLvgVtkqYqKRdWIwOiXubebgel+06UpSxyooo35mI3OZ99SBAM+rCLB6V2nNGN1rM3DHYni91O/xJGCpX+U0knB02LgpAg5M8TUhsVb295ghd6 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000010, 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. NOTE: David already applied the two btrfs patches to his tree but I've left them in the series to make the build bot happy. 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 (22): 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 btrfs: repair: use __bio_add_page for adding single page btrfs: raid56: use __bio_add_page to add single page 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: check if adding pages to clone bio fails block: mark bio_add_page as __must_check block: add __bio_add_folio fs: iomap: use __bio_add_folio 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 | 9 ++++++++- 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/btrfs/bio.c | 2 +- fs/btrfs/raid56.c | 2 +- fs/buffer.c | 2 +- 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 | 5 +++-- mm/page_io.c | 8 ++++---- 21 files changed, 65 insertions(+), 47 deletions(-) base-commit: af67688dca57999fd848f051eeea1d375ba546b2 Reviewed-by: Sergey Senozhatsky