Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp1692254ybs; Tue, 26 May 2020 00:59:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx85xFSCHtjhT4yY7tnVEFaBq1Fc9hLOI9sNbhiGCBgRCxs3+Ie4SbjBs3CP85lxYO4mSx9 X-Received: by 2002:aa7:d0cc:: with SMTP id u12mr19084087edo.385.1590479942700; Tue, 26 May 2020 00:59:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590479942; cv=none; d=google.com; s=arc-20160816; b=JBuYto/kyl9cAptKUYw6Ow/XxlxqOQkcqE0v+rnnYwebB86hS3abwqk34IIh5a2men S35aBJRdbOfZqvHdvf9U9Ly+P+/jp//J9SsGxSwC+ru1VmPv5PFLvhkNE7Joiv97lKcp hYwlxm7NkJntpXEgh5DmbFMHTRnn1/djCzHooheTbWTR5M9qVOYuBwb2kHPPsmg693vU eReAgl1vXPjAwGaTk7D1WlY4tlR/bZWQh6bxPSe6MY4l/QLD7An19IuPUXpAYibmEEeh 5gky5sNxq8GucXQOCTsV2O5OTH1tjOJGRMhX1x53z58aKSQOCMvfUJq1XHf4Nrm0ZB0N O+WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=bNGHW3QAq2Xq+UJSiXiTpyMVPsEfj0aZO+VBnhJ9YQs=; b=z+y2QTJKPnfRKvmThN/BpWtsm10h7gN1Wm9kpNyIielWEIxC1ttyfhl3kxGsCfs0bH hr6zRMRFd46SgUGVI/ET8MyfGuRkTOMhw25QtAHnTE5+6B2x/cbHTSjlwoaSZgt4jdKL E2+TELUl6CEFY+uwRa0empbfTzImV52dV54zzJTjDlxwTorae58Lb4l895yhIh2fTHHB CvQiBr1tvztS3l7hn9jm/H8RKKAZ1lPhzQGDgt7BCwGUwbB5MoWAXFIzTsQ2OxQU4Nrb j6u9wPRjQjxp4ByZtzMfEaVy2Ub1qA7/QpOoefhIt+HD3jUhXodrhcFiEJVAZKAQS2E9 WaFg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z7si10227358edr.172.2020.05.26.00.58.39; Tue, 26 May 2020 00:59:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731353AbgEZHTV (ORCPT + 99 others); Tue, 26 May 2020 03:19:21 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:4896 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726809AbgEZHTV (ORCPT ); Tue, 26 May 2020 03:19:21 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 038D9DF6CCD7E8D1452C; Tue, 26 May 2020 15:19:15 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.487.0; Tue, 26 May 2020 15:19:07 +0800 From: "zhangyi (F)" To: CC: , , , , Subject: [PATCH 02/10] fs: pick out ll_rw_one_block() helper function Date: Tue, 26 May 2020 15:17:46 +0800 Message-ID: <20200526071754.33819-3-yi.zhang@huawei.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200526071754.33819-1-yi.zhang@huawei.com> References: <20200526071754.33819-1-yi.zhang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.124.28] X-CFilter-Loop: Reflected Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Pick out ll_rw_one_block() helper function from ll_rw_block() for submitting one locked buffer for reading/writing. Signed-off-by: zhangyi (F) --- fs/buffer.c | 41 ++++++++++++++++++++++--------------- include/linux/buffer_head.h | 1 + 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index a60f60396cfa..3a2226f88b2d 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -3081,6 +3081,29 @@ int submit_bh(int op, int op_flags, struct buffer_head *bh) } EXPORT_SYMBOL(submit_bh); +void ll_rw_one_block(int op, int op_flags, struct buffer_head *bh) +{ + BUG_ON(!buffer_locked(bh)); + + if (op == WRITE) { + if (test_clear_buffer_dirty(bh)) { + bh->b_end_io = end_buffer_write_sync; + get_bh(bh); + submit_bh(op, op_flags, bh); + return; + } + } else { + if (!buffer_uptodate(bh)) { + bh->b_end_io = end_buffer_read_sync; + get_bh(bh); + submit_bh(op, op_flags, bh); + return; + } + } + unlock_buffer(bh); +} +EXPORT_SYMBOL(ll_rw_one_block); + /** * ll_rw_block: low-level access to block devices (DEPRECATED) * @op: whether to %READ or %WRITE @@ -3116,22 +3139,8 @@ void ll_rw_block(int op, int op_flags, int nr, struct buffer_head *bhs[]) if (!trylock_buffer(bh)) continue; - if (op == WRITE) { - if (test_clear_buffer_dirty(bh)) { - bh->b_end_io = end_buffer_write_sync; - get_bh(bh); - submit_bh(op, op_flags, bh); - continue; - } - } else { - if (!buffer_uptodate(bh)) { - bh->b_end_io = end_buffer_read_sync; - get_bh(bh); - submit_bh(op, op_flags, bh); - continue; - } - } - unlock_buffer(bh); + + ll_rw_one_block(op, op_flags, bh); } } EXPORT_SYMBOL(ll_rw_block); diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 15b765a181b8..11aa412c0bcd 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -198,6 +198,7 @@ struct buffer_head *alloc_buffer_head(gfp_t gfp_flags); void free_buffer_head(struct buffer_head * bh); void unlock_buffer(struct buffer_head *bh); void __lock_buffer(struct buffer_head *bh); +void ll_rw_one_block(int op, int op_flags, struct buffer_head *bh); void ll_rw_block(int, int, int, struct buffer_head * bh[]); int sync_dirty_buffer(struct buffer_head *bh); int __sync_dirty_buffer(struct buffer_head *bh, int op_flags); -- 2.21.3