From patchwork Thu Apr 11 21:08:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jerome Glisse X-Patchwork-Id: 10896875 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 820AF1708 for ; Thu, 11 Apr 2019 21:10:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7273428B00 for ; Thu, 11 Apr 2019 21:10:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6630428DF8; Thu, 11 Apr 2019 21:10:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9CC728B00 for ; Thu, 11 Apr 2019 21:10:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726730AbfDKVKF (ORCPT ); Thu, 11 Apr 2019 17:10:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33370 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727180AbfDKVJD (ORCPT ); Thu, 11 Apr 2019 17:09:03 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AFE38309E9A7; Thu, 11 Apr 2019 21:09:02 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.20.6.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4018C5C220; Thu, 11 Apr 2019 21:09:01 +0000 (UTC) From: jglisse@redhat.com To: linux-kernel@vger.kernel.org Cc: =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-mm@kvack.org, John Hubbard , Jan Kara , Dan Williams , Alexander Viro , Johannes Thumshirn , Christoph Hellwig , Jens Axboe , Ming Lei , Dave Chinner , Jason Gunthorpe , Matthew Wilcox Subject: [PATCH v1 09/15] block: bvec_put_page_dirty* instead of set_page_dirty* and bvec_put_page Date: Thu, 11 Apr 2019 17:08:28 -0400 Message-Id: <20190411210834.4105-10-jglisse@redhat.com> In-Reply-To: <20190411210834.4105-1-jglisse@redhat.com> References: <20190411210834.4105-1-jglisse@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 11 Apr 2019 21:09:02 +0000 (UTC) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jérôme Glisse Use bvec_put_page_dirty*() instead of set_page_dirty*() followed by a call to bvec_put_page(). With this change we can use the proper put_user_page*() helpers. Signed-off-by: Jérôme Glisse Cc: linux-fsdevel@vger.kernel.org Cc: linux-block@vger.kernel.org Cc: linux-mm@kvack.org Cc: John Hubbard Cc: Jan Kara Cc: Dan Williams Cc: Alexander Viro Cc: Johannes Thumshirn Cc: Christoph Hellwig Cc: Jens Axboe Cc: Ming Lei Cc: Dave Chinner Cc: Jason Gunthorpe Cc: Matthew Wilcox --- block/bio.c | 8 ++------ fs/block_dev.c | 8 +++----- fs/ceph/file.c | 6 +----- fs/cifs/misc.c | 8 +++----- 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/block/bio.c b/block/bio.c index b74b81085f3a..efd254c90974 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1448,12 +1448,8 @@ static void __bio_unmap_user(struct bio *bio) /* * make sure we dirty pages we wrote to */ - bio_for_each_segment_all(bvec, bio, i, iter_all) { - if (bio_data_dir(bio) == READ) - set_page_dirty_lock(bvec_page(bvec)); - - bvec_put_page(bvec); - } + bio_for_each_segment_all(bvec, bio, i, iter_all) + bvec_put_page_dirty_lock(bvec, bio_data_dir(bio) == READ); bio_put(bio); } diff --git a/fs/block_dev.c b/fs/block_dev.c index 9761f7943774..16a17fae6694 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -261,11 +261,9 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter, } __set_current_state(TASK_RUNNING); - bio_for_each_segment_all(bvec, &bio, i, iter_all) { - if (should_dirty && !PageCompound(bvec_page(bvec))) - set_page_dirty_lock(bvec_page(bvec)); - bvec_put_page(bvec); - } + bio_for_each_segment_all(bvec, &bio, i, iter_all) + bvec_put_page_dirty_lock(bvec, should_dirty && + !PageCompound(bvec_page(bvec))); if (unlikely(bio.bi_status)) ret = blk_status_to_errno(bio.bi_status); diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 6a39347f4956..d5561662b902 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -160,11 +160,7 @@ static void put_bvecs(struct bio_vec *bvecs, int num_bvecs, bool should_dirty) int i; for (i = 0; i < num_bvecs; i++) { - if (bvec_page(&bvecs[i])) { - if (should_dirty) - set_page_dirty_lock(bvec_page(&bvecs[i])); - bvec_put_page(&bvecs[i]); - } + bvec_put_page_dirty_lock(&bvecs[i], should_dirty); } kvfree(bvecs); } diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c index 86d78f297526..bc77a4a5f1af 100644 --- a/fs/cifs/misc.c +++ b/fs/cifs/misc.c @@ -800,11 +800,9 @@ cifs_aio_ctx_release(struct kref *refcount) if (ctx->bv) { unsigned i; - for (i = 0; i < ctx->npages; i++) { - if (ctx->should_dirty) - set_page_dirty(bvec_page(&ctx->bv[i])); - bvec_put_page(&ctx->bv[i]); - } + for (i = 0; i < ctx->npages; i++) + bvec_put_page_dirty_lock(&ctx->bv[i], + ctx->should_dirty); kvfree(ctx->bv); }