From patchwork Wed Jul 15 20:12:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill O'Donnell X-Patchwork-Id: 11666167 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3D09B722 for ; Wed, 15 Jul 2020 20:13:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2691F20663 for ; Wed, 15 Jul 2020 20:13:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Txt/9FaS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727067AbgGOUNI (ORCPT ); Wed, 15 Jul 2020 16:13:08 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:24084 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726780AbgGOUNI (ORCPT ); Wed, 15 Jul 2020 16:13:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594843987; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Hg84eDl8Foij0F8hyxIHWT0pDGrpEEv3CmiZv/rb7NQ=; b=Txt/9FaSXjaSOEbreUO9W4TsWlMP8bg/TzXxRJSbLHqI//BLOeHamrSwREuNagzXlHJlCo AMToiyV/vHk+Jl0Iw/LfCbn2YkJMHs2N6AUTIpUGykPQv5jQ0xYzq8oEyM5TXYpAhKZLjd YhgPPLm/9hapz4cW3URqqU9rdjnbPDo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-440-fu4yc128N9eNaTbGOO6ArQ-1; Wed, 15 Jul 2020 16:13:04 -0400 X-MC-Unique: fu4yc128N9eNaTbGOO6ArQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B79A21083; Wed, 15 Jul 2020 20:13:03 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-87.rdu2.redhat.com [10.10.116.87]) by smtp.corp.redhat.com (Postfix) with ESMTP id 329F460BF1; Wed, 15 Jul 2020 20:13:03 +0000 (UTC) From: Bill O'Donnell To: linux-xfs@vger.kernel.org Cc: sandeen@sandeen.net, darrick.wong@oracle.com Subject: [PATCH 1/3] xfsprogs: xfs_quota command error message improvement Date: Wed, 15 Jul 2020 15:12:51 -0500 Message-Id: <20200715201253.171356-2-billodo@redhat.com> In-Reply-To: <20200715201253.171356-1-billodo@redhat.com> References: <20200715201253.171356-1-billodo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Make the error messages for rudimentary xfs_quota commands (off, enable, disable) more user friendly, instead of the terse sys error outputs. Signed-off-by: Bill O'Donnell Reviewed-by: Darrick J. Wong --- quota/state.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/quota/state.c b/quota/state.c index 8f9718f1..7a595fc6 100644 --- a/quota/state.c +++ b/quota/state.c @@ -306,8 +306,16 @@ enable_enforcement( return; } dir = mount->fs_name; - if (xfsquotactl(XFS_QUOTAON, dir, type, 0, (void *)&qflags) < 0) - perror("XFS_QUOTAON"); + if (xfsquotactl(XFS_QUOTAON, dir, type, 0, (void *)&qflags) < 0) { + if (errno == EEXIST) + fprintf(stderr, + _("Quota enforcement already enabled.\n")); + else if (errno == EINVAL || errno == ENOSYS) + fprintf(stderr, + _("Can't enable enforcement when quota off.\n")); + else + perror("XFS_QUOTAON"); + } else if (flags & VERBOSE_FLAG) state_quotafile_mount(stdout, type, mount, flags); } @@ -328,8 +336,16 @@ disable_enforcement( return; } dir = mount->fs_name; - if (xfsquotactl(XFS_QUOTAOFF, dir, type, 0, (void *)&qflags) < 0) - perror("XFS_QUOTAOFF"); + if (xfsquotactl(XFS_QUOTAOFF, dir, type, 0, (void *)&qflags) < 0) { + if (errno == EEXIST) + fprintf(stderr, + _("Quota enforcement already disabled.\n")); + else if (errno == EINVAL || errno == ENOSYS) + fprintf(stderr, + _("Can't disable enforcement when quota off.\n")); + else + perror("XFS_QUOTAOFF"); + } else if (flags & VERBOSE_FLAG) state_quotafile_mount(stdout, type, mount, flags); } @@ -350,8 +366,12 @@ quotaoff( return; } dir = mount->fs_name; - if (xfsquotactl(XFS_QUOTAOFF, dir, type, 0, (void *)&qflags) < 0) - perror("XFS_QUOTAOFF"); + if (xfsquotactl(XFS_QUOTAOFF, dir, type, 0, (void *)&qflags) < 0) { + if (errno == EEXIST || errno == ENOSYS) + fprintf(stderr, _("Quota already off.\n")); + else + perror("XFS_QUOTAOFF"); + } else if (flags & VERBOSE_FLAG) state_quotafile_mount(stdout, type, mount, flags); } From patchwork Wed Jul 15 20:12:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill O'Donnell X-Patchwork-Id: 11666171 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A36AB913 for ; Wed, 15 Jul 2020 20:13:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7F6DC20663 for ; Wed, 15 Jul 2020 20:13:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BHQtjZ5b" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726780AbgGOUNN (ORCPT ); Wed, 15 Jul 2020 16:13:13 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:39933 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727078AbgGOUNM (ORCPT ); Wed, 15 Jul 2020 16:13:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594843991; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aK/IK6yRzaYCILg60K6kPUcEYS6Gn6oZdiMx/DR25QE=; b=BHQtjZ5bst4DCJ4htcgTWwwlR9rY7zR/fDyfaVn8wyPg7uarxMM3QC8kM2Yp3K4BtbRXua tG2GPKics4WRQv2laP23uF6lMm7IUCofXfT29a+rurYPfrkukAAwfrxCW7GzbBtSQmwY/v e2irvedkfMkcbuBFZ5LD5m98Zg0Hhys= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-349-KUKyMfm9PeONs7EylQO9bQ-1; Wed, 15 Jul 2020 16:13:05 -0400 X-MC-Unique: KUKyMfm9PeONs7EylQO9bQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4D9A210059AB; Wed, 15 Jul 2020 20:13:04 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-87.rdu2.redhat.com [10.10.116.87]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB6F660BF1; Wed, 15 Jul 2020 20:13:03 +0000 (UTC) From: Bill O'Donnell To: linux-xfs@vger.kernel.org Cc: sandeen@sandeen.net, darrick.wong@oracle.com Subject: [PATCH 2/3] xfs_quota: display warning limits when printing quota type information Date: Wed, 15 Jul 2020 15:12:52 -0500 Message-Id: <20200715201253.171356-3-billodo@redhat.com> In-Reply-To: <20200715201253.171356-1-billodo@redhat.com> References: <20200715201253.171356-1-billodo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: "Darrick J. Wong" We should dump the default warning limits when we're printing quota information. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- quota/state.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/quota/state.c b/quota/state.c index 7a595fc6..1627181d 100644 --- a/quota/state.c +++ b/quota/state.c @@ -130,6 +130,16 @@ state_timelimit( time_to_string(timelimit, VERBOSE_FLAG | ABSOLUTE_FLAG)); } +static void +state_warnlimit( + FILE *fp, + uint form, + uint16_t warnlimit) +{ + fprintf(fp, _("%s max warnings: %u\n"), + form_to_string(form), warnlimit); +} + /* * fs_quota_stat holds a subset of fs_quota_statv; this copies * the smaller into the larger, leaving any not-present fields @@ -218,7 +228,11 @@ state_quotafile_mount( sv.qs_flags & XFS_QUOTA_PDQ_ENFD); state_timelimit(fp, XFS_BLOCK_QUOTA, sv.qs_btimelimit); + state_warnlimit(fp, XFS_BLOCK_QUOTA, sv.qs_bwarnlimit); + state_timelimit(fp, XFS_INODE_QUOTA, sv.qs_itimelimit); + state_warnlimit(fp, XFS_INODE_QUOTA, sv.qs_iwarnlimit); + state_timelimit(fp, XFS_RTBLOCK_QUOTA, sv.qs_rtbtimelimit); } From patchwork Wed Jul 15 20:12:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill O'Donnell X-Patchwork-Id: 11666169 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 85F28722 for ; Wed, 15 Jul 2020 20:13:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6FB5020663 for ; Wed, 15 Jul 2020 20:13:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZcaXyp7k" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727104AbgGOUNM (ORCPT ); Wed, 15 Jul 2020 16:13:12 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:22874 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726780AbgGOUNL (ORCPT ); Wed, 15 Jul 2020 16:13:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594843989; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wIwMqWILJ+v4fswH5Jt1hU3CL4KYa/Sadu45p8aQ0Lg=; b=ZcaXyp7kG1SWME7nxwqYsXOc+TNl/L7+eey4ZCjiLpYdZj4WTm0bBIiLtVyzacs8xP+dpg wbxJGAniKWU59JNCx4rPDNOixrOVRUvJS8/VpLVqHoaSva9+EF6wvFbDRaNcOKx9OPUnUK IeYcgMvi4p7p/EPRn8SERaEI1EPsWcs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-170-KIZKHzXdOSGDofRz7tC9IQ-1; Wed, 15 Jul 2020 16:13:05 -0400 X-MC-Unique: KIZKHzXdOSGDofRz7tC9IQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D6C861085; Wed, 15 Jul 2020 20:13:04 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-87.rdu2.redhat.com [10.10.116.87]) by smtp.corp.redhat.com (Postfix) with ESMTP id 711CE60BF1; Wed, 15 Jul 2020 20:13:04 +0000 (UTC) From: Bill O'Donnell To: linux-xfs@vger.kernel.org Cc: sandeen@sandeen.net, darrick.wong@oracle.com Subject: [PATCH 3/3] xfsprogs: xfs_quota state command should report ugp grace times Date: Wed, 15 Jul 2020 15:12:53 -0500 Message-Id: <20200715201253.171356-4-billodo@redhat.com> In-Reply-To: <20200715201253.171356-1-billodo@redhat.com> References: <20200715201253.171356-1-billodo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Since grace periods are now supported for three quota types (ugp), modify xfs_quota state command to report times for all three. Add a helper function for stat reporting. Signed-off-by: Bill O'Donnell --- quota/state.c | 108 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 80 insertions(+), 28 deletions(-) diff --git a/quota/state.c b/quota/state.c index 1627181d..5aadcca2 100644 --- a/quota/state.c +++ b/quota/state.c @@ -190,6 +190,39 @@ state_stat_to_statv( } } +static void +state_quotafile_stat( + FILE *fp, + uint type, + struct fs_path *mount, + struct fs_quota_statv *sv) +{ + switch(type) { + case XFS_USER_QUOTA: + state_qfilestat(fp, mount, XFS_USER_QUOTA, &sv->qs_uquota, + sv->qs_flags & XFS_QUOTA_UDQ_ACCT, + sv->qs_flags & XFS_QUOTA_UDQ_ENFD); + break; + case XFS_GROUP_QUOTA: + state_qfilestat(fp, mount, XFS_GROUP_QUOTA, &sv->qs_gquota, + sv->qs_flags & XFS_QUOTA_GDQ_ACCT, + sv->qs_flags & XFS_QUOTA_GDQ_ENFD); + break; + case XFS_PROJ_QUOTA: + state_qfilestat(fp, mount, XFS_PROJ_QUOTA, &sv->qs_pquota, + sv->qs_flags & XFS_QUOTA_PDQ_ACCT, + sv->qs_flags & XFS_QUOTA_PDQ_ENFD); + break; + } + state_timelimit(fp, XFS_BLOCK_QUOTA, sv->qs_btimelimit); + state_warnlimit(fp, XFS_BLOCK_QUOTA, sv->qs_bwarnlimit); + + state_timelimit(fp, XFS_INODE_QUOTA, sv->qs_itimelimit); + state_warnlimit(fp, XFS_INODE_QUOTA, sv->qs_iwarnlimit); + + state_timelimit(fp, XFS_RTBLOCK_QUOTA, sv->qs_rtbtimelimit); +} + static void state_quotafile_mount( FILE *fp, @@ -203,37 +236,56 @@ state_quotafile_mount( sv.qs_version = FS_QSTATV_VERSION1; - if (xfsquotactl(XFS_GETQSTATV, dev, type, 0, (void *)&sv) < 0) { - if (xfsquotactl(XFS_GETQSTAT, dev, type, 0, (void *)&s) < 0) { - if (flags & VERBOSE_FLAG) - fprintf(fp, - _("%s quota are not enabled on %s\n"), - type_to_string(type), dev); - return; + if (type & XFS_USER_QUOTA) { + if (xfsquotactl(XFS_GETQSTATV, dev, XFS_USER_QUOTA, + 0, (void *)&sv) < 0) { + if (xfsquotactl(XFS_GETQSTAT, dev, XFS_USER_QUOTA, + 0, (void *)&s) < 0) { + if (flags & VERBOSE_FLAG) + fprintf(fp, + _("%s quota are not enabled on %s\n"), + type_to_string(XFS_USER_QUOTA), + dev); + return; + } + state_stat_to_statv(&s, &sv); } - state_stat_to_statv(&s, &sv); + state_quotafile_stat(fp, XFS_USER_QUOTA, mount, &sv); } - if (type & XFS_USER_QUOTA) - state_qfilestat(fp, mount, XFS_USER_QUOTA, &sv.qs_uquota, - sv.qs_flags & XFS_QUOTA_UDQ_ACCT, - sv.qs_flags & XFS_QUOTA_UDQ_ENFD); - if (type & XFS_GROUP_QUOTA) - state_qfilestat(fp, mount, XFS_GROUP_QUOTA, &sv.qs_gquota, - sv.qs_flags & XFS_QUOTA_GDQ_ACCT, - sv.qs_flags & XFS_QUOTA_GDQ_ENFD); - if (type & XFS_PROJ_QUOTA) - state_qfilestat(fp, mount, XFS_PROJ_QUOTA, &sv.qs_pquota, - sv.qs_flags & XFS_QUOTA_PDQ_ACCT, - sv.qs_flags & XFS_QUOTA_PDQ_ENFD); - - state_timelimit(fp, XFS_BLOCK_QUOTA, sv.qs_btimelimit); - state_warnlimit(fp, XFS_BLOCK_QUOTA, sv.qs_bwarnlimit); - - state_timelimit(fp, XFS_INODE_QUOTA, sv.qs_itimelimit); - state_warnlimit(fp, XFS_INODE_QUOTA, sv.qs_iwarnlimit); - - state_timelimit(fp, XFS_RTBLOCK_QUOTA, sv.qs_rtbtimelimit); + if (type & XFS_GROUP_QUOTA) { + if (xfsquotactl(XFS_GETQSTATV, dev, XFS_GROUP_QUOTA, + 0, (void *)&sv) < 0) { + if (xfsquotactl(XFS_GETQSTAT, dev, XFS_GROUP_QUOTA, + 0, (void *)&s) < 0) { + if (flags & VERBOSE_FLAG) + fprintf(fp, + _("%s quota are not enabled on %s\n"), + type_to_string(XFS_GROUP_QUOTA), + dev); + return; + } + state_stat_to_statv(&s, &sv); + } + state_quotafile_stat(fp, XFS_GROUP_QUOTA, mount, &sv); + } + + if (type & XFS_PROJ_QUOTA) { + if (xfsquotactl(XFS_GETQSTATV, dev, XFS_PROJ_QUOTA, + 0, (void *)&sv) < 0) { + if (xfsquotactl(XFS_GETQSTAT, dev, XFS_PROJ_QUOTA, + 0, (void *)&s) < 0) { + if (flags & VERBOSE_FLAG) + fprintf(fp, + _("%s quota are not enabled on %s\n"), + type_to_string(XFS_PROJ_QUOTA), + dev); + return; + } + state_stat_to_statv(&s, &sv); + } + state_quotafile_stat(fp, XFS_PROJ_QUOTA, mount, &sv); + } } static void