Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932897AbcKPHXt (ORCPT ); Wed, 16 Nov 2016 02:23:49 -0500 Received: from out0-148.mail.aliyun.com ([140.205.0.148]:42834 "EHLO out0-148.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932124AbcKPHXm (ORCPT ); Wed, 16 Nov 2016 02:23:42 -0500 X-Greylist: delayed 339 seconds by postgrey-1.27 at vger.kernel.org; Wed, 16 Nov 2016 02:23:40 EST X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R121e4;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e02c03303;MF=hillf.zj@alibaba-inc.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---.7B8q5x0_1479280653; Reply-To: "Hillf Danton" From: "Hillf Danton" To: "'Jens Axboe'" , "'Andrew Morton'" Cc: , , , "'Linus Torvalds'" References: <6e2dec0d-cef5-60ac-2cf6-a89ded82e2f4@kernel.dk> In-Reply-To: <6e2dec0d-cef5-60ac-2cf6-a89ded82e2f4@kernel.dk> Subject: Re: [PATCH] mm: don't cap request size based on read-ahead setting Date: Wed, 16 Nov 2016 15:17:33 +0800 Message-ID: <000701d23fd9$805dcdd0$81196970$@alibaba-inc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQJp0L/wygrTIPhB0q+KhENdBXDSb5+sD/iA Content-Language: zh-cn Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1007 Lines: 28 On Wednesday, November 16, 2016 12:31 PM Jens Axboe wrote: > @@ -369,10 +369,25 @@ ondemand_readahead(struct address_space *mapping, > bool hit_readahead_marker, pgoff_t offset, > unsigned long req_size) > { > - unsigned long max = ra->ra_pages; > + unsigned long io_pages, max_pages; > pgoff_t prev_offset; > > /* > + * If bdi->io_pages is set, that indicates the (soft) max IO size > + * per command for that device. If we have that available, use > + * that as the max suitable read-ahead size for this IO. Instead of > + * capping read-ahead at ra_pages if req_size is larger, we can go > + * up to io_pages. If io_pages isn't set, fall back to using > + * ra_pages as a safe max. > + */ > + io_pages = inode_to_bdi(mapping->host)->io_pages; > + if (io_pages) { > + max_pages = max_t(unsigned long, ra->ra_pages, req_size); > + io_pages = min(io_pages, max_pages); Doubt if you mean max_pages = min(io_pages, max_pages); > + } else > + max_pages = ra->ra_pages; > +