From patchwork Tue May 30 15:49:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13260547 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 E934AC7EE2C for ; Tue, 30 May 2023 15:49:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 59AFD900003; Tue, 30 May 2023 11:49:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 54AB2900002; Tue, 30 May 2023 11:49:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 41269900003; Tue, 30 May 2023 11:49:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 31D6C900002 for ; Tue, 30 May 2023 11:49:37 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0B0581601F9 for ; Tue, 30 May 2023 15:49:37 +0000 (UTC) X-FDA: 80847356394.09.6AD1BC5 Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by imf02.hostedemail.com (Postfix) with ESMTP id 4746B8001B for ; Tue, 30 May 2023 15:49:33 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=BiBH5KSs; spf=pass (imf02.hostedemail.com: domain of "prvs=507b913ec=johannes.thumshirn@wdc.com" designates 216.71.154.42 as permitted sender) smtp.mailfrom="prvs=507b913ec=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=1685461774; 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=jnhclB6/ARA+cGJTOMmmcadsSQD4Ywu/u90r/VIgeuo=; b=63kqESzeD+tDhDQs2H1wwj6/+EZGTbFGl+dJcQYhQq+LO0qLYj6OAUSxfrMolIxq0Vcvsy ncAVjVEl0b/ieI1/yBi+1OMh85h1If9fedUPiQwwVus4p1gE1leRcgLctV4liuKKjDaHaP r2jtGpvqn+YPhc1Xk7gHYOFnEucDPeI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685461774; a=rsa-sha256; cv=none; b=iLBwffVJbMHCVFM9nMOw0p7w0ghPJv8dkYw3m8RP8Y0O27W/t4mBuI+QWe5Lcovti3VO0x aMTpGHz7ytRjVtx87Rgf+P52R1kD5T/lroW+PGkqiYFsqQqcmN8toT/RgYbOqCxJc4aITB HmHHlsD3obdNE9744qmZE8Opo/wt77w= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=BiBH5KSs; spf=pass (imf02.hostedemail.com: domain of "prvs=507b913ec=johannes.thumshirn@wdc.com" designates 216.71.154.42 as permitted sender) smtp.mailfrom="prvs=507b913ec=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=1685461774; x=1716997774; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=LvvitQpZZtAL6oj1gqbFnc01A5MrDrOWTWrqLbLHBtg=; b=BiBH5KSs1V2j/x4x45PtZZyXte5Il5PfkUYOaiAN0rzh7hCWolz9EPdO GoNZntOvrgBHBYdqyIIEbO8RUlBTUcLOxXRnVFmQinDmiVdCsJBqmc2I/ UNpuUvA1aYxkugN/ZgycPXjwgyGFT7sivOpqNxPti59uX2lJ+JKK+D6QS LGaobXtG2THjHxSrhAtYDjRbRZFrCKS3vnlyHC4VDVezLjb7VjEyb1nUC xhT/25xY4o/KZROMqV+Ilbm8TaO4rHhBvDc5Y2CEy8keBFw1VMzWexlcG nel11F8KiqwexsGkfy02OLA3bWSI2J0uqhYLtkg9in26Dum33y4ahGn18 Q==; X-IronPort-AV: E=Sophos;i="6.00,204,1681142400"; d="scan'208";a="230129723" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 30 May 2023 23:49:29 +0800 IronPort-SDR: kYOXvpd+liHP7011lgv8asAKdZdabb58SRh7nDjmdbUtdpGx7nVDg/6ipmG6ILjrHLk/uawYhr jXf8oPY9C9BP4PZtqeng90rkFT0iYprT7MdhsfswqbZYGKGqNc/zQqijt0t6dikXBf6+h8SJtG d/n/yCyWww0fq3ZkC9rU4svxy6u5d0Exy6hvRvSEtV23j8lSXFemc8orBcLolQfHnQfD83aMA7 xCpKbEr8SAw7cX8ZgwJ52hJ3XHsKoSNX5OhDIsmWfS6PzzwPm4kPGQzI/aMOhrF/hyCaUoxaJd N30= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 30 May 2023 07:58:41 -0700 IronPort-SDR: UZ8AC9JVcWItXvBURdFJfv2biVq9H2WKi13hcXxNmWmdGCl2msIehsW5OQj1211e+TheiYsP0z f/u4ZWFf/I1HZ2VD7ZgIa4wS+N2+wjgThSQMa1tPWp1wb3hH2n3ospDXQkzLVPAAbhWcu2/tEI SBqKpnvb6T+sxHwXStTtNJyZxUdL6nv8qHGMBJ3g70NYauvzNiwuU67Q4Y1/R+PJCILKB5A8CO jEOWy50NKKPkI9VlZ2fe3M709Dt9/hM2gbd5kOLisv33sJeeo1JhbeqNpeDbTlV5YHAtNPTvrC PxQ= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.6]) by uls-op-cesaip02.wdc.com with ESMTP; 30 May 2023 08:49:26 -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 , gouhao@uniontech.com, Johannes Thumshirn Subject: [PATCH v6 00/20] bio: check return values of bio_add_page Date: Tue, 30 May 2023 08:49:03 -0700 Message-Id: X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: 4746B8001B X-Rspam-User: X-Stat-Signature: w37skejwzrfgfq17e49tzguqu3idotam X-Rspamd-Server: rspam03 X-HE-Tag: 1685461773-680296 X-HE-Meta: U2FsdGVkX1+UaZBiwMZO+6+hd6S23Pf+fqVTKTuXAsJ1XdTShAkIhUsml3rDUlopx4VudSOX1zla3fE7Gx/dfniN51+EioK9e3Iryhji1ykUR4PB7R+pR5uwKDNAAWM6HnOEJnt+RUcp/f256IakdG2Dq/cSG6jacCistLtxosILujylM+TqTZnYiEV8XPn2Hh4AOsD8+m2KEGQNnDPv60TZlcFSnKhPD0UbQBuA9cD+eDC9u9WZAIraWKQ2VF9hEVYxDVe85La4AbZZ1RF5ulcMX/ZMayfzbZzjo61L8CU8NqtmmUoaATNvAQ1RAv2TwfwIy7iCatP0JRpuvLk2kUxgouZ/K3xf6YhvYEJE1qfmrCzlf0vqf/4lWuRAOsgd5MSGTcBw6Z5JsxM/I6I1DyvW4FElE8aK4rS0Qb3EfOt2w30d3I1tQnAdxHRVSq+UKd+S1VD9FwQKnTe/xm1D+NHDfy4xIkLHwQsKVG0GcP3qXzrj9G6B+Y0A9cjr5+hMY63897ewO+5UUbyDMT9vidG8dFQzsDMKpE1zvgvh70YknQbU/AkiXaSxOHNqoEZ9h8j/WtcAH6NQ5EvC0mVkZyJ2ToKF965mAMyOQiJO/tsRN36oYk+XSrRV6uIBSU00bBd+rfZGLSB9Vj5Nt8FAH3fi5GB4kTIqcE8LEW9f4gMJpKaBcO8LDKxZy70JbX+yQf3FG+vJ6SW1LbKBIPutUHHEr8IpZ6YHjuokeoN0rUzre3hgEI4kX52e4x8mXHACwzTBoGxUA6Oqkd5/VAwhCpzkSyadmAaFIMEsMfCJZArJ1v3d97COcV2WETiK6Phw8YRet9UE4kfJKL6Xk4mBxsSIxHnyAFvyhxfWwdK5x6kqi4VRykZF7dXvfyrqt83pcrah9IkG7jaz5dzVChnrVJhxgddXxQV+lIqOBo/9yxkinTqL/cnHZufJ67ymQYEiCvpNZfbhDbzXbkc4kgd eFNeeAB4 1TAp7K/rWNWHz3Oi2Ik/TX8NFZKe6U8U1AASFTtiZpkSoYzCkSNJ8GJJ1adiBGDCHusG1zpn110XoyqW4IVb65yNLO/Ws+g4/vFxr3Flj73pGycUZI5p29qPAsolCUlhEnGc4ir9Ffs4ZTuuKYQT8GdI57pYGWnyKGttCYT35ui1DycvCfctNloJEqM5Gs0QtwQ+j10hOgOKjzIkUedr6+UlSKKtniPZUzOMOPZFuKs4e4yS/dIDyrPMsGYZiyzI+02kXuA9ibac1sIe7Yd6KTwyo5Bw0a7Uo17eE8b5+ApR7xHTmQ0sf838JuDuGYri6fZOk1LapXS4+luhlz9ZFXt3tgg== 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 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: 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 | 5 ++++- 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 | 5 +++-- mm/page_io.c | 8 ++++---- 19 files changed, 59 insertions(+), 46 deletions(-)