Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4152007imu; Fri, 30 Nov 2018 11:58:54 -0800 (PST) X-Google-Smtp-Source: AFSGD/XhKtzpjELfqpNRP5O+8eov3MkJM9I+Y6RpHquuwugGPxASSC170+ZYRjYw6UQgkmBdxq5f X-Received: by 2002:a63:ec13:: with SMTP id j19mr5844812pgh.6.1543607934212; Fri, 30 Nov 2018 11:58:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543607934; cv=none; d=google.com; s=arc-20160816; b=ZWK8v6xJmmR8zM/CuETJFKlzvrEgmDt0McXmk7cmNqGRdEpcZHngVfEt2tz5j8DG1h 3zuh7P95vrX6T1A0kqNeHbYFZoEH8DSVjgQEmbupNlT3NG8vQ4XQMUvf9U6TDyxPHhXz XuGWZHk+xQg81w8ArHIxY+c3BT36OAb4SxPjoZKI8Tlk2chO4BGjutCenlXUH9qAIX2r aVVAn9LH5BqQJDjuzSl4ZSv5ATxi8+jVn5BQwkmMTThG4q78mfnSbrPPvTxcD90p9Ug9 zmhUU9os1Rz/olJTT/QOCbe+Xquz5pPQ/oDXz5dTBwq94TXs9xcY4bhNysXNTQia6inb H1Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=lDemUPEMWm+oRHcUjNq0mhWEwrrriN+plSLSXai9Pwg=; b=Kr1d/78/3Mfy7xnoJxb47ODAc41PM9CsrmgKF0Sfgbmtf22kyxerNJ41aQqm+pAvzQ RjHkQ5lcPG8EEkCpVR+MdKWq0titiiHUoTgEWydC0v5MK+mbIpFFiDrsVmoSYCSQsuO9 tEBhcL4BCS53ZTI4IHsx6dOaBkj3LVNRcmketi7z0nBVFQkUuvaypF5CJ9JBCSxbO3pz XxDqx3y4CbPn6f/dFffww4RJUWpGJ6IvF5Bi6Er3z6cxtxqvxtgu3lWPq7G/6HgHHoxV 1y11O1bbB3nWkyYTeA1A9hzmzeYOhFDQmhLdUH5Jqu2mj9UmwK/F9KmBeJTShiLJy1dm eMeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@osandov-com.20150623.gappssmtp.com header.s=20150623 header.b=jYUNXSIV; 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 a2si5705182pgd.461.2018.11.30.11.58.40; Fri, 30 Nov 2018 11:58:54 -0800 (PST) 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; dkim=pass header.i=@osandov-com.20150623.gappssmtp.com header.s=20150623 header.b=jYUNXSIV; 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 S1726816AbeLAHGd (ORCPT + 99 others); Sat, 1 Dec 2018 02:06:33 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:45978 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726778AbeLAHGc (ORCPT ); Sat, 1 Dec 2018 02:06:32 -0500 Received: by mail-pg1-f196.google.com with SMTP id y4so2923638pgc.12 for ; Fri, 30 Nov 2018 11:56:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=lDemUPEMWm+oRHcUjNq0mhWEwrrriN+plSLSXai9Pwg=; b=jYUNXSIVnlKz7M8TAXjqIDWejbvySOYSRFbOWE0XjR57tAwFDRMM5YRj5ZhajyF/Yo oujR/g4XKNNpESh7iagA49ZrwGLB3rbBa5H1od/26BZ528tlfR0XjQSLGvHsGCpQBpgh SBytB4LV+DojW2BhP7pFG30o1EOQ4BbLbXNwGe10wOa+1R2DC4w0QTrPefdVP6aDZsRp t7aSph2A0n1hxtYygmmI7VXPudtLsX1I/ovgpICLfo4Oz+YgAis/cuwTzTkSpQFtZovV qGUulOaT7r3Zmx9WNVrmOCM9cP9IN7KxlRZeXF7E7eR9vXHw5ycIPLgdYJHyeWIrpkDV eodg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=lDemUPEMWm+oRHcUjNq0mhWEwrrriN+plSLSXai9Pwg=; b=bLDflVwZtdonG+h05PPUjsUSLvx0P4UaEjnZt7Ro5946G0A7a0GbNN7elrtGhEsodK sOzNv0VstC5aQC/515zdoOBh1LMjmwuEsELg3PMJuEqIpMblGf+6XhlIbx6L1sWGI3tw jQ17L7Gwob2+IPJ9sCW9vqEm83+auGr9EN44g/jpozroy6UNJrC8H8o+D0gNUhUxtXhC vwHqOHssY3b5VXhMju2j/qW5ewUpcUc6E6APVy07TaEuzyVceixkTGt3BFemWt3saCXr NNmqrmtqvENHjBNGnxc/EbxM18y5No0HiFryESDQ9zDOSdvGz81jkVBvyG4oA0rvcGdA yKWw== X-Gm-Message-State: AA+aEWY2RMNnFbJUKwbpWRA5UwV0ziSLvtkP23v6hBL5jgSFF2VuPW4L aTI7uqYgRiVOkA0VbILfXiUcVA== X-Received: by 2002:a62:5182:: with SMTP id f124mr6947172pfb.238.1543607769002; Fri, 30 Nov 2018 11:56:09 -0800 (PST) Received: from vader ([2620:10d:c090:200::4:705d]) by smtp.gmail.com with ESMTPSA id i73sm12321942pfi.66.2018.11.30.11.56.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Nov 2018 11:56:08 -0800 (PST) Date: Fri, 30 Nov 2018 11:56:07 -0800 From: Omar Sandoval To: Huijin Park Cc: Andreas Dilger , Michael Callahan , Omar Sandoval , js07.lee@samsung.com, Huijin Park , linux-block@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH,1/2] genhd: avoid overflow of sectors in disk_stats Message-ID: <20181130195607.GA27411@vader> References: <1543570361-3168-1-git-send-email-huijin.park@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1543570361-3168-1-git-send-email-huijin.park@samsung.com> User-Agent: Mutt/1.11.0 (2018-11-25) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 30, 2018 at 04:32:40AM -0500, Huijin Park wrote: > From: "huijin.park" > > This patch changes the 'sectors' type to an u64. > In 32 bit system, the 'sectors' can accumulate up to about 2TiB. > If a 32 bit system makes i/o over 2TiB while running, > the 'sectors' will overflow. > As a result, the part_stat_read(sectors), the diskstats in proc and > the (lifetime|session)_write_kbytes in sysfs return invalid statistic. What about parsers which expect it to be an unsigned long? E.g., iostat: https://github.com/sysstat/sysstat/blob/v12.1.1/rd_stats.c#L736 At least with glibc, scanf seems to truncate sanely, but this appears to be undefined. > Signed-off-by: huijin.park > --- > block/genhd.c | 6 +++--- > include/linux/genhd.h | 2 +- > 2 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/block/genhd.c b/block/genhd.c > index 0145bcb..7518dcd 100644 > --- a/block/genhd.c > +++ b/block/genhd.c > @@ -1343,10 +1343,10 @@ static int diskstats_show(struct seq_file *seqf, void *v) > part_stat_unlock(); > part_in_flight(gp->queue, hd, inflight); > seq_printf(seqf, "%4d %7d %s " > - "%lu %lu %lu %u " > - "%lu %lu %lu %u " > + "%lu %lu %llu %u " > + "%lu %lu %llu %u " > "%u %u %u " > - "%lu %lu %lu %u\n", > + "%lu %lu %llu %u\n", > MAJOR(part_devt(hd)), MINOR(part_devt(hd)), > disk_name(gp, hd->partno, buf), > part_stat_read(hd, ios[STAT_READ]), > diff --git a/include/linux/genhd.h b/include/linux/genhd.h > index 0c5ee17..5bf86f9 100644 > --- a/include/linux/genhd.h > +++ b/include/linux/genhd.h > @@ -84,7 +84,7 @@ struct partition { > > struct disk_stats { > u64 nsecs[NR_STAT_GROUPS]; > - unsigned long sectors[NR_STAT_GROUPS]; > + u64 sectors[NR_STAT_GROUPS]; > unsigned long ios[NR_STAT_GROUPS]; > unsigned long merges[NR_STAT_GROUPS]; > unsigned long io_ticks; > -- > 1.7.9.5 >