From patchwork Tue Dec 27 15:55:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9489457 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 046C262AB0 for ; Tue, 27 Dec 2016 16:04:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EAD60201BC for ; Tue, 27 Dec 2016 16:04:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF9D9223B2; Tue, 27 Dec 2016 16:04:25 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham 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 83B632094F for ; Tue, 27 Dec 2016 16:04:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755243AbcL0QAc (ORCPT ); Tue, 27 Dec 2016 11:00:32 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:33809 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752216AbcL0P7v (ORCPT ); Tue, 27 Dec 2016 10:59:51 -0500 Received: by mail-pg0-f68.google.com with SMTP id b1so12788779pgc.1; Tue, 27 Dec 2016 07:58:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0vWDwzERcaLxY7MUaxN2PNUEPgHF1K5QvWkTJ9mub1k=; b=Whc5JCtLb4t7sbPtZk4HqVPP9e6wLqGHj8StFvhdr7+WmMKlzLvHSBbCRsAks0mYeg m5QDTyTQTAz9mefBAaR8Kycs3yps/UC3vKCykFjKw7aqOqv5HVIUU1JRn9dq9daT70l1 0hdEz8y98oMxaUyLdGKbVb9IVFCuECEmmRM82CEl/4+GcUYhArhPo8hEI7n79gW0gmS8 clv1ISJ/dbWEcxaEXRgOWm30B+vQVVMHn4yjwhTsTUF0L49nwvelonOHDH66ySg2iTVf pQzB9RAzxZsBXY9CY0TJ+GBByO228HwmkY/SX7qkN/A22WdkaYaaM0qNF8C2mv+teIxi aziw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0vWDwzERcaLxY7MUaxN2PNUEPgHF1K5QvWkTJ9mub1k=; b=cev7SizjPNQDt8+5Gb0SGZUb2F/Z7nPmEXa64m9YXHS6kY29mx6xTQaOfs1WU9otnr l+tLDW2RTs/xjytWMc2MdEKplqukG7RJJdo88mIa2cHCFR97FKKOAMZEGprj6E2fIVqT PN2OIKtsCJ0Y6GIEJqRta0c3OPXVgWjpoxHnnPs8td85piMEbH5PJ89hHyGSfIaPHtfc Ws0SVkj/ypJuTsSujwtVY4fzxpIi05G2MQjYuNerCRPc1R8R7D2USCndCGxl4LPIYulQ IuOywTXVmyzP8ZI1jZrXf2NLZYsSWfSXUKvOKSOBC5kuT9uQ7Dg5D7MYK+LGAeYp5Dog 8NUw== X-Gm-Message-State: AIkVDXILoPtsQjB+Ccjj7neGBQMO54a7p4M9snN6IqVx6xm7H9dKRYmiTyRWNxuPlpbwJQ== X-Received: by 10.99.37.2 with SMTP id l2mr59205988pgl.160.1482854336721; Tue, 27 Dec 2016 07:58:56 -0800 (PST) Received: from localhost ([45.35.47.137]) by smtp.gmail.com with ESMTPSA id q27sm90657500pfd.49.2016.12.27.07.58.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Dec 2016 07:58:55 -0800 (PST) From: Ming Lei To: Jens Axboe , linux-kernel@vger.kernel.org Cc: linux-block@vger.kernel.org, Christoph Hellwig , Ming Lei , Alexander Viro , linux-fsdevel@vger.kernel.org (open list:FILESYSTEMS (VFS and infrastructure)) Subject: [PATCH v1 05/54] fs/buffer: comment on direct access to bvec table Date: Tue, 27 Dec 2016 23:55:54 +0800 Message-Id: <1482854250-13481-6-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1482854250-13481-1-git-send-email-tom.leiming@gmail.com> References: <1482854250-13481-1-git-send-email-tom.leiming@gmail.com> 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 Signed-off-by: Ming Lei --- fs/buffer.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/buffer.c b/fs/buffer.c index d21771fcf7d3..63d2f40c21fd 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -3060,8 +3060,13 @@ static void end_bio_bh_io_sync(struct bio *bio) void guard_bio_eod(int op, struct bio *bio) { sector_t maxsector; - struct bio_vec *bvec = &bio->bi_io_vec[bio->bi_vcnt - 1]; unsigned truncated_bytes; + /* + * It is safe to truncate the last bvec in the following way + * even though multipage bvec is supported, but we need to + * fix the parameters passed to zero_user(). + */ + struct bio_vec *bvec = &bio->bi_io_vec[bio->bi_vcnt - 1]; maxsector = i_size_read(bio->bi_bdev->bd_inode) >> 9; if (!maxsector)