Received: by 10.223.164.221 with SMTP id h29csp853942wrb; Tue, 24 Oct 2017 10:23:21 -0700 (PDT) X-Google-Smtp-Source: ABhQp+QMIpRr5tNEP1wQ6mmeK0uwWLjn+bn1lTNqDlbjssDjaA3PTyD/mMaLMlqRclqkAcChVJCo X-Received: by 10.98.130.203 with SMTP id w194mr17381397pfd.308.1508865801155; Tue, 24 Oct 2017 10:23:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508865801; cv=none; d=google.com; s=arc-20160816; b=1D4u46eFAL4bqX5PnmeAtr9MYOeLREBI2XOOstzWiJrzcz0jZqZIRIGyQZZQ0DieE/ xvdMaGRn5RlUSIVZrl+ByXXmUrh7OPUGQwzC26isnn6trsNhhy1GYx+6D8tyjSoHgYIv HwGcNcXMHe9fjlSWEOaAg7wqgcpCLOObGg7v7RW/WJ7ZRO3rb8Z/3RbYNbQ0sHWYeptS Muf1voz/wlBBoELebtOnJqyI666EpskC/SSYvQrSW/gkzrS+t7tIXeuB/IVN3xr0PMRB PvzLDlz2kpZDQaiw1MfAOlJoF7L2TumYhu1MYAatgAAH5ku4zQFmC0YBKi2lxxYJ5xiJ d9AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=5GLzozPcB+T7mW7Lx+salM5FKKSW5E40tqLlJDC516o=; b=Yq/JeigAc87Da2fcDDYhLgxgNTG5XNPZoCDgGxATpaD9RpoXkTn2J/G/WluJ0+ge+X quTODLHdcGj3uczGcqezXCkOrCE3I1MtXN27q9p6vYIqcA2AkQfE4je0mBW8GWHYht9H kLb11tHQzGo8m2OE64IFgXfBnOjXgOXi0P5udvtYdfGb+KB3a+WWmLEx6wYQ3gvL0g7s UV+41yKP5qZHfnnEjvpVDg0YDb32BQfAME8TtQc6eR4LAXW+dL4HBBcdjbhkJvESeoqq 4yiRoXKaI/w8G5cOuHedc0aGVkKkrCX7greudeMLxjBQlgdWlGjuvA9Ei/vuFxe6Ez/B sW9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p2si381602plk.358.2017.10.24.10.23.06; Tue, 24 Oct 2017 10:23:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751856AbdJXRWn (ORCPT + 99 others); Tue, 24 Oct 2017 13:22:43 -0400 Received: from legacy.ddn.com ([64.47.133.206]:48572 "EHLO legacy.ddn.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751756AbdJXRWm (ORCPT ); Tue, 24 Oct 2017 13:22:42 -0400 Received: from LAX-EX-CAHT1.datadirect.datadirectnet.com (10.8.103.81) by LAX-EX-CAHT2.datadirect.datadirectnet.com (10.8.103.82) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 24 Oct 2017 10:22:41 -0700 Received: from psuche.colorado.datadirectnet.com (10.8.30.128) by LAX-EX-CAHT1.datadirect.datadirectnet.com (10.8.103.81) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 24 Oct 2017 10:22:41 -0700 From: Greg Edwards To: CC: Christoph Hellwig , Al Viro , "Jens Axboe" , , Greg Edwards Subject: [PATCH v2] fs: guard_bio_eod() needs to consider partitions Date: Tue, 24 Oct 2017 11:21:48 -0600 Message-ID: <20171024172148.12397-1-gedwards@ddn.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171024011007.24855-1-gedwards@ddn.com> References: <20171024011007.24855-1-gedwards@ddn.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.8.30.128] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org guard_bio_eod() needs to look at the partition capacity, not just the capacity of the whole device, when determining if truncation is necessary. [ 60.268688] attempt to access beyond end of device [ 60.268690] unknown-block(9,1): rw=0, want=67103509, limit=67103506 [ 60.268693] buffer_io_error: 2 callbacks suppressed [ 60.268696] Buffer I/O error on dev md1p7, logical block 4524305, async page read Fixes: 74d46992e0d9 ("block: replace bi_bdev with a gendisk pointer and partitions index") Signed-off-by: Greg Edwards --- Changes from v1: * use __disk_get_part instead of disk_get_part, similar to what blk_partition_remap does fs/buffer.c | 10 +++++++++- include/linux/genhd.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/fs/buffer.c b/fs/buffer.c index 170df856bdb9..b96f3b98a6ef 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -3055,8 +3055,16 @@ 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; + struct hd_struct *part; + + rcu_read_lock(); + part = __disk_get_part(bio->bi_disk, bio->bi_partno); + if (part) + maxsector = part_nr_sects_read(part); + else + maxsector = get_capacity(bio->bi_disk); + rcu_read_unlock(); - maxsector = get_capacity(bio->bi_disk); if (!maxsector) return; diff --git a/include/linux/genhd.h b/include/linux/genhd.h index ea652bfcd675..cb8c5fd74b71 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -242,6 +242,7 @@ static inline dev_t part_devt(struct hd_struct *part) return part_to_dev(part)->devt; } +extern struct hd_struct *__disk_get_part(struct gendisk *disk, int partno); extern struct hd_struct *disk_get_part(struct gendisk *disk, int partno); static inline void disk_put_part(struct hd_struct *part) -- 2.13.6 From 1582153187985463397@xxx Tue Oct 24 15:27:40 +0000 2017 X-GM-THRID: 1582099735264682689 X-Gmail-Labels: Inbox,Category Forums