From patchwork Tue Dec 27 16:05:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9489521 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 2BD6762AB0 for ; Tue, 27 Dec 2016 16:08:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DCC4200E7 for ; Tue, 27 Dec 2016 16:08:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 123BC2621E; Tue, 27 Dec 2016 16:08:48 +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=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 BD6EB201BC for ; Tue, 27 Dec 2016 16:08:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933136AbcL0QHr (ORCPT ); Tue, 27 Dec 2016 11:07:47 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:32879 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932582AbcL0QHd (ORCPT ); Tue, 27 Dec 2016 11:07:33 -0500 Received: by mail-pf0-f194.google.com with SMTP id 127so8381713pfg.0; Tue, 27 Dec 2016 08:07:33 -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=9l1LHLlcr4Qhl2j170xbaO8dNQv8+92Z5UlrDjYekpc=; b=uhi0qlUdVeMYQrKRhVw6JdQaGepF7N1w7C28HQnsbmV3zBcUmf/2zylOZ6I93oOGyE MXUVdwUSEqrHZRb2qEyAW8ROJ3Enczrl5XhFBVL1EtEp8pdSmTpWdAIvAFct6mR0ItT9 fhqFOepnq1LMxeQlXJ7INCqhQkVdcEjL6XIE+k2SP3+/WcxAsNGQGuJDULAijL/+lNuP SW0VyUoutB0jRhPTtFUcQuBAnuKUc8cUaApKwqOBBreOynwCqarkWUlfG4a430jRQ33x n14PYBqYEMfQNut4UJXrSF1LoJAbYC7PMstJM9yE59xOi+aXOqjSMiRYF8AJ9aDEh8Fw /wQA== 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=9l1LHLlcr4Qhl2j170xbaO8dNQv8+92Z5UlrDjYekpc=; b=WIdnn0sL8saYeEFOBsRzBs04CoM8+c05j5QSl0AMQDUhaBcbFx/Ha2taPSNXJIYywD oGppLIsuZZDalswM1hzkPaQtOJjsnoOvimt8SOxVMczyRzYWT1Jy+OBWvnd/LWeaFPv9 yjDpn+uYl/7nUhGDiznIlEVA0aVQYuHooB7PhqvWD/G1raMD8+X/+Aj+7rGm0vnc0HT8 QaCmQHgV1pawhWW84n7aVE5V8o1YAHVlEKuwd6SZQBIDDBjYy5ZMamRLL4UgaVAoSvIs VJ3POF3y9p9ju0buVNQv5toEVw+hh9nhIhsVqg/kr6RBQY4qoC34ZlL7gxRF73KlItXt EfOg== X-Gm-Message-State: AIkVDXI2QBxm66GYf8uUUPidTZOaeco0fwBtykntYcb3h9sH+jx66m4WVsV2l8BGMyLtfA== X-Received: by 10.84.162.204 with SMTP id o12mr68884065plg.17.1482854852599; Tue, 27 Dec 2016 08:07:32 -0800 (PST) Received: from localhost ([45.35.47.137]) by smtp.gmail.com with ESMTPSA id c15sm90730477pfd.36.2016.12.27.08.07.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Dec 2016 08:07:29 -0800 (PST) From: Ming Lei To: Jens Axboe , linux-kernel@vger.kernel.org Cc: linux-block@vger.kernel.org, Christoph Hellwig , Ming Lei , Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org (open list:BTRFS FILE SYSTEM) Subject: [PATCH v1 53/54] btrfs: comment on direct access bvec table Date: Wed, 28 Dec 2016 00:05:02 +0800 Message-Id: <1482854706-14128-22-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1482854706-14128-1-git-send-email-tom.leiming@gmail.com> References: <1482854706-14128-1-git-send-email-tom.leiming@gmail.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Ming Lei --- fs/btrfs/compression.c | 4 ++++ fs/btrfs/inode.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index 485a60923bba..54306dee392a 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -601,6 +601,10 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, /* we need the actual starting offset of this extent in the file */ read_lock(&em_tree->lock); + /* + * It is still safe to retrieve the 1st page of the bio + * in this way after supporting multipage bvec. + */ em = lookup_extent_mapping(em_tree, page_offset(bio->bi_io_vec->bv_page), PAGE_SIZE); diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index fa77cb210907..d0714208495f 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -7914,6 +7914,11 @@ static int dio_read_error(struct inode *inode, struct bio *failed_bio, return -EIO; } + /* + * In this case it is still correct to retrieve length + * of the 1st bvec of the bio in this way after supporting + * multipage bvec. + */ if ((bio_segments_all(failed_bio) > 1) || (failed_bio->bi_io_vec->bv_len > btrfs_inode_sectorsize(inode))) @@ -7960,6 +7965,12 @@ static void btrfs_retry_endio_nocsum(struct bio *bio) if (bio->bi_error) goto end; + /* + * WARNING: + * + * With multipage bvec, the following way of direct access to + * bvec table is only safe if the bio includes single page. + */ ASSERT(bio->bi_vcnt == 1); inode = bio->bi_io_vec->bv_page->mapping->host; ASSERT(bio->bi_io_vec->bv_len == btrfs_inode_sectorsize(inode)); @@ -8045,6 +8056,12 @@ static void btrfs_retry_endio(struct bio *bio) start = done->start; + /* + * WARNING: + * + * With multipage bvec, the following way of direct access to + * bvec table is only safe if the bio includes single page. + */ ASSERT(bio->bi_vcnt == 1); inode = bio->bi_io_vec->bv_page->mapping->host; ASSERT(bio->bi_io_vec->bv_len == btrfs_inode_sectorsize(inode));