From owner-svn-src-all@freebsd.org Tue Jul 16 23:12:28 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 55154BCDEA; Tue, 16 Jul 2019 23:12:28 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 343FB8218B; Tue, 16 Jul 2019 23:12:28 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 17A6FD8A2; Tue, 16 Jul 2019 23:12:28 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x6GNCRvI081349; Tue, 16 Jul 2019 23:12:27 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x6GNCR3E081347; Tue, 16 Jul 2019 23:12:27 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <201907162312.x6GNCR3E081347@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Tue, 16 Jul 2019 23:12:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r350070 - in head/sys/ufs: ffs ufs X-SVN-Group: head X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: in head/sys/ufs: ffs ufs X-SVN-Commit-Revision: 350070 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 343FB8218B X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.95)[-0.948,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Jul 2019 23:12:28 -0000 Author: mckusick Date: Tue Jul 16 23:12:27 2019 New Revision: 350070 URL: https://svnweb.freebsd.org/changeset/base/350070 Log: When a process attempts to allocate space on a full filesystem, a filesystem full message is sent to the offending process or the kernel log if the offending process cannot be identified. To prevent an explotion of messages, the kernel ppsratecheck() function is used to limit the messages to one per second. This revision changes the variable that tracks the rate of these messages from a systemwide limit to a per-filesystem limit by moving it from a global variable to a variable in the ufsmount structure. Suggested by: kib Reviewed by: kib Sponsored by: Netflix Modified: head/sys/ufs/ffs/ffs_alloc.c head/sys/ufs/ffs/ffs_balloc.c head/sys/ufs/ufs/ufsmount.h Modified: head/sys/ufs/ffs/ffs_alloc.c ============================================================================== --- head/sys/ufs/ffs/ffs_alloc.c Tue Jul 16 22:59:15 2019 (r350069) +++ head/sys/ufs/ffs/ffs_alloc.c Tue Jul 16 23:12:27 2019 (r350070) @@ -158,8 +158,6 @@ ffs_alloc(ip, lbn, bpref, size, flags, cred, bnp) struct ufsmount *ump; ufs2_daddr_t bno; u_int cg, reclaimed; - static struct timeval lastfail; - static int curfail; int64_t delta; #ifdef QUOTA int error; @@ -224,11 +222,14 @@ nospace: softdep_request_cleanup(fs, ITOV(ip), cred, FLUSH_BLOCKS_WAIT); goto retry; } - UFS_UNLOCK(ump); - if (reclaimed > 0 && ppsratecheck(&lastfail, &curfail, 1)) { + if (reclaimed > 0 && + ppsratecheck(&ump->um_last_fullmsg, &ump->um_secs_fullmsg, 1)) { + UFS_UNLOCK(ump); ffs_fserr(fs, ip->i_number, "filesystem full"); uprintf("\n%s: write failed, filesystem is full\n", fs->fs_fsmnt); + } else { + UFS_UNLOCK(ump); } return (ENOSPC); } @@ -258,8 +259,6 @@ ffs_realloccg(ip, lbprev, bprev, bpref, osize, nsize, u_int cg, request, reclaimed; int error, gbflags; ufs2_daddr_t bno; - static struct timeval lastfail; - static int curfail; int64_t delta; vp = ITOV(ip); @@ -449,14 +448,17 @@ nospace: softdep_request_cleanup(fs, vp, cred, FLUSH_BLOCKS_WAIT); goto retry; } - UFS_UNLOCK(ump); - if (bp) - brelse(bp); - if (reclaimed > 0 && ppsratecheck(&lastfail, &curfail, 1)) { + if (reclaimed > 0 && + ppsratecheck(&ump->um_last_fullmsg, &ump->um_secs_fullmsg, 1)) { + UFS_UNLOCK(ump); ffs_fserr(fs, ip->i_number, "filesystem full"); uprintf("\n%s: write failed, filesystem is full\n", fs->fs_fsmnt); + } else { + UFS_UNLOCK(ump); } + if (bp) + brelse(bp); return (ENOSPC); } @@ -1101,8 +1103,6 @@ ffs_valloc(pvp, mode, cred, vpp) ino_t ino, ipref; u_int cg; int error, error1, reclaimed; - static struct timeval lastfail; - static int curfail; *vpp = NULL; pip = VTOI(pvp); @@ -1193,11 +1193,13 @@ noinodes: softdep_request_cleanup(fs, pvp, cred, FLUSH_INODES_WAIT); goto retry; } - UFS_UNLOCK(ump); - if (ppsratecheck(&lastfail, &curfail, 1)) { + if (ppsratecheck(&ump->um_last_fullmsg, &ump->um_secs_fullmsg, 1)) { + UFS_UNLOCK(ump); ffs_fserr(fs, pip->i_number, "out of inodes"); uprintf("\n%s: create/symlink failed, no inodes free\n", fs->fs_fsmnt); + } else { + UFS_UNLOCK(ump); } return (ENOSPC); } Modified: head/sys/ufs/ffs/ffs_balloc.c ============================================================================== --- head/sys/ufs/ffs/ffs_balloc.c Tue Jul 16 22:59:15 2019 (r350069) +++ head/sys/ufs/ffs/ffs_balloc.c Tue Jul 16 23:12:27 2019 (r350070) @@ -108,8 +108,6 @@ ffs_balloc_ufs1(struct vnode *vp, off_t startoffset, i ufs2_daddr_t *lbns_remfree, lbns[UFS_NIADDR + 1]; int unwindidx = -1; int saved_inbdflush; - static struct timeval lastfail; - static int curfail; int gbflags, reclaimed; ip = VTOI(vp); @@ -315,17 +313,21 @@ retry: if ((error = ffs_alloc(ip, lbn, pref, (int)fs->fs_bsize, flags | IO_BUFLOCKED, cred, &newb)) != 0) { brelse(bp); + UFS_LOCK(ump); if (DOINGSOFTDEP(vp) && ++reclaimed == 1) { - UFS_LOCK(ump); softdep_request_cleanup(fs, vp, cred, FLUSH_BLOCKS_WAIT); UFS_UNLOCK(ump); goto retry; } - if (ppsratecheck(&lastfail, &curfail, 1)) { + if (ppsratecheck(&ump->um_last_fullmsg, + &ump->um_secs_fullmsg, 1)) { + UFS_UNLOCK(ump); ffs_fserr(fs, ip->i_number, "filesystem full"); uprintf("\n%s: write failed, filesystem " "is full\n", fs->fs_fsmnt); + } else { + UFS_UNLOCK(ump); } goto fail; } @@ -394,17 +396,21 @@ retry: flags | IO_BUFLOCKED, cred, &newb); if (error) { brelse(bp); + UFS_LOCK(ump); if (DOINGSOFTDEP(vp) && ++reclaimed == 1) { - UFS_LOCK(ump); softdep_request_cleanup(fs, vp, cred, FLUSH_BLOCKS_WAIT); UFS_UNLOCK(ump); goto retry; } - if (ppsratecheck(&lastfail, &curfail, 1)) { + if (ppsratecheck(&ump->um_last_fullmsg, + &ump->um_secs_fullmsg, 1)) { + UFS_UNLOCK(ump); ffs_fserr(fs, ip->i_number, "filesystem full"); uprintf("\n%s: write failed, filesystem " "is full\n", fs->fs_fsmnt); + } else { + UFS_UNLOCK(ump); } goto fail; } @@ -582,8 +588,6 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, i int deallocated, osize, nsize, num, i, error; int unwindidx = -1; int saved_inbdflush; - static struct timeval lastfail; - static int curfail; int gbflags, reclaimed; ip = VTOI(vp); @@ -902,17 +906,21 @@ retry: if ((error = ffs_alloc(ip, lbn, pref, (int)fs->fs_bsize, flags | IO_BUFLOCKED, cred, &newb)) != 0) { brelse(bp); + UFS_LOCK(ump); if (DOINGSOFTDEP(vp) && ++reclaimed == 1) { - UFS_LOCK(ump); softdep_request_cleanup(fs, vp, cred, FLUSH_BLOCKS_WAIT); UFS_UNLOCK(ump); goto retry; } - if (ppsratecheck(&lastfail, &curfail, 1)) { + if (ppsratecheck(&ump->um_last_fullmsg, + &ump->um_secs_fullmsg, 1)) { + UFS_UNLOCK(ump); ffs_fserr(fs, ip->i_number, "filesystem full"); uprintf("\n%s: write failed, filesystem " "is full\n", fs->fs_fsmnt); + } else { + UFS_UNLOCK(ump); } goto fail; } @@ -982,17 +990,21 @@ retry: flags | IO_BUFLOCKED, cred, &newb); if (error) { brelse(bp); + UFS_LOCK(ump); if (DOINGSOFTDEP(vp) && ++reclaimed == 1) { - UFS_LOCK(ump); softdep_request_cleanup(fs, vp, cred, FLUSH_BLOCKS_WAIT); UFS_UNLOCK(ump); goto retry; } - if (ppsratecheck(&lastfail, &curfail, 1)) { + if (ppsratecheck(&ump->um_last_fullmsg, + &ump->um_secs_fullmsg, 1)) { + UFS_UNLOCK(ump); ffs_fserr(fs, ip->i_number, "filesystem full"); uprintf("\n%s: write failed, filesystem " "is full\n", fs->fs_fsmnt); + } else { + UFS_UNLOCK(ump); } goto fail; } Modified: head/sys/ufs/ufs/ufsmount.h ============================================================================== --- head/sys/ufs/ufs/ufsmount.h Tue Jul 16 22:59:15 2019 (r350069) +++ head/sys/ufs/ufs/ufsmount.h Tue Jul 16 23:12:27 2019 (r350070) @@ -100,6 +100,8 @@ struct ufsmount { char um_qflags[MAXQUOTAS]; /* (i) quota specific flags */ int64_t um_savedmaxfilesize; /* (c) track maxfilesize */ u_int um_flags; /* (i) filesystem flags */ + struct timeval um_last_fullmsg; /* (i) last full msg time */ + int um_secs_fullmsg; /* (i) seconds since full msg */ u_int um_trim_inflight; /* (i) outstanding trim count */ u_int um_trim_inflight_blks; /* (i) outstanding trim blks */ u_long um_trim_total; /* (i) total trim count */