From owner-freebsd-current@freebsd.org Mon Aug 20 19:53:47 2018 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C8246107AF42; Mon, 20 Aug 2018 19:53:46 +0000 (UTC) (envelope-from mckusick@mckusick.com) Received: from chez.mckusick.com (chez.mckusick.com [70.36.157.235]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 56F9F7F2A4; Mon, 20 Aug 2018 19:53:46 +0000 (UTC) (envelope-from mckusick@mckusick.com) Received: from chez.mckusick.com (localhost [IPv6:::1]) by chez.mckusick.com (8.15.2/8.15.2) with ESMTP id w7KJx3iK072721; Mon, 20 Aug 2018 12:59:03 -0700 (PDT) (envelope-from mckusick@mckusick.com) Message-Id: <201808201959.w7KJx3iK072721@chez.mckusick.com> From: Kirk McKusick To: FreeBSD Current , FreeBSD Filesystems Subject: Re: CFT: TRIM Consolodation on UFS/FFS filesystems X-URL: http://WWW.McKusick.COM/ Reply-To: Kirk McKusick In-reply-to: <201808201940.w7KJeu29072094@chez.mckusick.com> Comments: In-reply-to Kirk McKusick message dated "Mon, 20 Aug 2018 12:40:56 -0700." MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <72719.1534795143.1@chez.mckusick.com> Date: Mon, 20 Aug 2018 12:59:03 -0700 X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,MISSING_MID, UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on chez.mckusick.com X-Mailman-Approved-At: Mon, 20 Aug 2018 20:44:40 +0000 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Aug 2018 19:53:47 -0000 From: Kirk McKusick To: FreeBSD Current , FreeBSD Filesystems Subject: CFT: TRIM Consolodation on UFS/FFS filesystems Date: Mon, 20 Aug 2018 12:40:56 -0700 Oops, forgot that attachments get stripped. Below are the diffs for gathering statistics. Sorry to those of you on Gmail for whom they will be mangled. Kirk McKusick =-=-= Index: sbin/mount/mount.c =================================================================== --- sbin/mount/mount.c (revision 338054) +++ sbin/mount/mount.c (working copy) @@ -686,6 +686,18 @@ prmount(struct statfs *sfp) for (i = 0; i < sizeof(sfp->f_fsid); i++) printf("%02x", ((u_char *)&sfp->f_fsid)[i]); } + if (sfp->f_trim_total != 0 || sfp->f_trim_total_blks != 0) + (void)printf(", TRIM: total %ju total blocks %ju", + (uintmax_t)sfp->f_trim_total, + (uintmax_t)sfp->f_trim_total_blks); + if (sfp->f_trim_inflight != 0 || sfp->f_trim_inflight_blks != 0) + (void)printf(", TRIM: inflight %ju inflight blocks %ju", + (uintmax_t)sfp->f_trim_inflight, + (uintmax_t)sfp->f_trim_inflight_blks); + if (sfp->f_pendingblks != 0 || sfp->f_pendingfiles != 0) + (void)printf(", pending blocks %ju, pending files %ju", + (uintmax_t)sfp->f_pendingblks, + (uintmax_t)sfp->f_pendingfiles); } (void)printf(")\n"); } Index: sys/sys/mount.h =================================================================== --- sys/sys/mount.h (revision 338054) +++ sys/sys/mount.h (working copy) @@ -85,7 +85,13 @@ struct statfs { uint64_t f_asyncwrites; /* count of async writes since mount */ uint64_t f_syncreads; /* count of sync reads since mount */ uint64_t f_asyncreads; /* count of async reads since mount */ - uint64_t f_spare[10]; /* unused spare */ + uint64_t f_trim_total; /* count of TRIM ops since mount */ + uint64_t f_trim_total_blks; /* count of TRIM blocks since mount */ + uint64_t f_trim_inflight; /* count of TRIM ops in progress */ + uint64_t f_trim_inflight_blks; /* count of TRIM blocks in progress */ + int64_t f_pendingblks; /* pending free blocks */ + int64_t f_pendingfiles; /* pending free nodes */ + uint64_t f_spare[4]; /* unused spare */ uint32_t f_namemax; /* maximum filename length */ uid_t f_owner; /* user that mounted the filesystem */ fsid_t f_fsid; /* filesystem id */ Index: sys/ufs/ffs/ffs_vfsops.c =================================================================== --- sys/ufs/ffs/ffs_vfsops.c (revision 338081) +++ sys/ufs/ffs/ffs_vfsops.c (working copy) @@ -1398,7 +1398,13 @@ ffs_statfs(mp, sbp) sbp->f_bsize = fs->fs_fsize; sbp->f_iosize = fs->fs_bsize; sbp->f_blocks = fs->fs_dsize; + sbp->f_pendingblks = dbtofsb(fs, fs->fs_pendingblocks); + sbp->f_pendingfiles = fs->fs_pendinginodes; UFS_LOCK(ump); + sbp->f_trim_total = ump->um_trim_total; + sbp->f_trim_total_blks = ump->um_trim_total_blks; + sbp->f_trim_inflight = ump->um_trim_inflight; + sbp->f_trim_inflight_blks = ump->um_trim_inflight_blks; sbp->f_bfree = fs->fs_cstotal.cs_nbfree * fs->fs_frag + fs->fs_cstotal.cs_nffree + dbtofsb(fs, fs->fs_pendingblocks); sbp->f_bavail = freespace(fs, fs->fs_minfree) +