Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp219132pxb; Fri, 5 Mar 2021 20:30:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJzBQ4aZbvttTsl0ryoyKPF2LSgW0td5gWOmSHPSdUMvG5l9Q1cKuNE+cHhSejgKVRKSXQqT X-Received: by 2002:aa7:c496:: with SMTP id m22mr12202874edq.292.1615005057956; Fri, 05 Mar 2021 20:30:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615005057; cv=none; d=google.com; s=arc-20160816; b=iwGxs7JbGhSgegSImAv8JaNxq1TLbe4UqxglqQOpSHwLTwl8OCmFoYzJer5fnNctPD SxbY+dvPBekcCkA2TJBB3bs2TxNhMF2qS2lIVaIil/9FzYo0sFEIEu+27jZsxE37ZR2x UrM+c2ab7XCArfCZ3N30ffYvFew+0VUwdpqo0b3enE4ynabkLTSazya0p8KnQyQpFjk7 QHGIMo73CVupGPQR8suZRAzahUaiq9zIiOTwKNdmJB1lDA9HyhtkuCbUi+1S4Y7e7W0U 5GbDjvxx+tOB85Yk2neV1Ppaxjmp7u6gvfRBGBeXOBdrkA7U23ckryOgodlxC5/VsbpG nQ8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5xCAjFV02GYYen6UTXN4SrBhgC7CieWo2gsnput/pug=; b=ucus3qsIY72ng1Ayhl0Xf1l0CNpf2pYIWImq0ZfI7S2RyAvs6Q6tg2qfC+J/2idzm3 tJRqbYRLISzEWywtFGoh5293tUHJFh2ZWj5RuRL+IW6O8wwK5F0cgOwQ0jFJ/wHK+x7R oo4mnYvM5NJYmV7XGeLBYBUdw3JUaX4HxEf7qNHLGXpZwH1YSUdLx/5L/Bz8rT/1xEoH 3itanDmppqhkTeRx6qPn0VRaTIx1mq99W/R8J7b7bzzRl/a0oCXYaBTaHVPPyniw4QIO JGND4LTRWwUV4twto5R8rtlqfJ4JJ99ogPxUDkl6Lm15ksBRS1stoAd89U488KVLSIT9 tHcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aol.com header.s=a2048 header.b=T5OBCQbN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=aol.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w2si2992095edc.92.2021.03.05.20.29.19; Fri, 05 Mar 2021 20:30:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@aol.com header.s=a2048 header.b=T5OBCQbN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=aol.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229672AbhCFEFb (ORCPT + 99 others); Fri, 5 Mar 2021 23:05:31 -0500 Received: from sonic303-23.consmr.mail.gq1.yahoo.com ([98.137.64.204]:36925 "EHLO sonic303-23.consmr.mail.gq1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229642AbhCFEE4 (ORCPT ); Fri, 5 Mar 2021 23:04:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1615003495; bh=5xCAjFV02GYYen6UTXN4SrBhgC7CieWo2gsnput/pug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=T5OBCQbNyw7f7o01WDIxcQb+znyozJ1w02PFLc6KdekE//0bAC3y3nOlQlBiYFtK+SVthYrocIHKbviZYjwLjrl26XV5EoSpAbrR4EiJgzHtzBsjE5AXDIrn3QEkrKr2IxfE2XHk3nSas4N6ZOv8LXFSEIRpveOwkT/ypRxoVVXkSEuDgsr801kpYDatI53wq83lMrm7HWK8YnfJMDKOqu9GeBGfo+u1r9lwn5tUXFUAjVG4dCxLOUXRatRx2LapIxZNKMHgYR4SsOdEA+jEEkPhxSv7wplztAelT8L2AITyiPPwjQzo8qDGSwpLg96DYBwHTTLIk5/D3oucKzJF1g== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1615003495; bh=ZSrR6YgRFqTlEYl1tOnFFtuXRFKzcCifZOKhjAKlxsn=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=OjZaefhqdaDzoQXOWS9fIcpmx+evN2lOdiusRxcNgrC5+Fd/1f6kc5NkeqB6xJd1eR5GxcbembOqN1za236RQXRzEQmpHkHhF2nqq7eP7IUiLMoQomqpbGwLZRQQy3W5L1TT4K6nYie3qpF0GgNLWgOvjEpvWpU1u+6RX+0iIyoe4Czq/8F5R5euC0Z6Twh+xgUnLzhBNVVjVigXC2W7mGkMOvwFc+71Grdu9UW7NRA9dGnHTnE0TcY4znhRPN2gEDhCM65Cjd25pmbRvPOUyJIFEt+w7EVkIexQCXPS4gQRXVu7ozFwyD4YidRENLMnEoemCKe1ibPuVYFZOIkA3Q== X-YMail-OSG: kucRKUwVM1kmlbcKa7NY8l4UABXRQeefKMNhN8lZfYr2dd_.vp9Se78s6YE6VwW NFQGWAWoea1GUVgNU19y61W6JK_doAiWgp1GEf6CX59LCXWw7mlq_jwoUGvi608Zi2grl2clT3cs kPJF.5irczsNk31lCr918UYb24JDIut1InWQ.tF7sDr4EfP.Dg9nySUYZsMegQT.nGSY2.uusuIK C.ZtBklYJynZu5gB4OUpDkOmN_bDJW7Bst8NAm0pFmTnUhgitADjj6ieFeyJJ9wVk8oW1aIL_Q0q zejLzvPK5Iz_wbZu8V4XkN_wLuusVUs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DQA7uGV1wvC.oJ.a1jWYv0w84PsCzfvpXU v98T6KW8FwzpuMbme2hfqzgqQLqkEYX51otzC9npvc1D4W3jdz0dvzqZqdf.dtjL9C9x0a5yjv5M 2nAHD8wn5k1z7NBENTiuKjnJybWCFLas0F3vWlH9bpcvaq8UYseJy3ElzWo4pOSuwqJ.2Me6cYvJ dKfd3_LMmkwMVsT0muLVD2Ma4A.lqlmSZDI57TCx2qeInu08ECJE7 X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic303.consmr.mail.gq1.yahoo.com with HTTP; Sat, 6 Mar 2021 04:04:55 +0000 Received: by kubenode526.mail-prod1.omega.gq1.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 8c5221a1eae591564358a3225682cbee; Sat, 06 Mar 2021 04:04:53 +0000 (UTC) From: Gao Xiang To: linux-erofs@lists.ozlabs.org, Chao Yu , Chao Yu Cc: linux-kernel@vger.kernel.org, Gao Xiang , Martin DEVERA Subject: [PATCH v2] erofs: fix bio->bi_max_vecs behavior change Date: Sat, 6 Mar 2021 12:04:38 +0800 Message-Id: <20210306040438.8084-1-hsiangkao@aol.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210306033109.28466-1-hsiangkao@aol.com> References: <20210306033109.28466-1-hsiangkao@aol.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Length: 3892 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gao Xiang Martin reported an issue that directory read could be hung on the latest -rc kernel with some certain image. The root cause is that commit baa2c7c97153 ("block: set .bi_max_vecs as actual allocated vector number") changes .bi_max_vecs behavior. bio->bi_max_vecs is set as actual allocated vector number rather than the requested number now. Let's avoid using .bi_max_vecs completely instead. Reported-by: Martin DEVERA Signed-off-by: Gao Xiang --- change since v1: - since bio->bi_max_vecs doesn't record extent blocks anymore, introduce a remaining extent block to avoid extent excess. fs/erofs/data.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/fs/erofs/data.c b/fs/erofs/data.c index f88851c5c250..1249e74b3bf0 100644 --- a/fs/erofs/data.c +++ b/fs/erofs/data.c @@ -129,6 +129,7 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio, struct page *page, erofs_off_t *last_block, unsigned int nblocks, + unsigned int *eblks, bool ra) { struct inode *const inode = mapping->host; @@ -145,8 +146,7 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio, /* note that for readpage case, bio also equals to NULL */ if (bio && - /* not continuous */ - *last_block + 1 != current_block) { + (*last_block + 1 != current_block || !*eblks)) { submit_bio_retry: submit_bio(bio); bio = NULL; @@ -216,7 +216,8 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio, if (nblocks > DIV_ROUND_UP(map.m_plen, PAGE_SIZE)) nblocks = DIV_ROUND_UP(map.m_plen, PAGE_SIZE); - bio = bio_alloc(GFP_NOIO, bio_max_segs(nblocks)); + *eblks = bio_max_segs(nblocks); + bio = bio_alloc(GFP_NOIO, *eblks); bio->bi_end_io = erofs_readendio; bio_set_dev(bio, sb->s_bdev); @@ -229,16 +230,8 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio, /* out of the extent or bio is full */ if (err < PAGE_SIZE) goto submit_bio_retry; - + --*eblks; *last_block = current_block; - - /* shift in advance in case of it followed by too many gaps */ - if (bio->bi_iter.bi_size >= bio->bi_max_vecs * PAGE_SIZE) { - /* err should reassign to 0 after submitting */ - err = 0; - goto submit_bio_out; - } - return bio; err_out: @@ -252,7 +245,6 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio, /* if updated manually, continuous pages has a gap */ if (bio) -submit_bio_out: submit_bio(bio); return err ? ERR_PTR(err) : NULL; } @@ -264,23 +256,26 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio, static int erofs_raw_access_readpage(struct file *file, struct page *page) { erofs_off_t last_block; + unsigned int eblks; struct bio *bio; trace_erofs_readpage(page, true); bio = erofs_read_raw_page(NULL, page->mapping, - page, &last_block, 1, false); + page, &last_block, 1, &eblks, false); if (IS_ERR(bio)) return PTR_ERR(bio); - DBG_BUGON(bio); /* since we have only one bio -- must be NULL */ + if (bio) + submit_bio(bio); return 0; } static void erofs_raw_access_readahead(struct readahead_control *rac) { erofs_off_t last_block; + unsigned int eblks; struct bio *bio = NULL; struct page *page; @@ -291,7 +286,7 @@ static void erofs_raw_access_readahead(struct readahead_control *rac) prefetchw(&page->flags); bio = erofs_read_raw_page(bio, rac->mapping, page, &last_block, - readahead_count(rac), true); + readahead_count(rac), &eblks, true); /* all the page errors are ignored when readahead */ if (IS_ERR(bio)) { @@ -305,7 +300,6 @@ static void erofs_raw_access_readahead(struct readahead_control *rac) put_page(page); } - /* the rare case (end in gaps) */ if (bio) submit_bio(bio); } -- 2.20.1