lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 15 Oct 2020 14:32:52 +0300
From:   Roman Anufriev <dotdot@...dex-team.ru>
To:     linux-ext4@...r.kernel.org
Cc:     tytso@....edu, jack@...e.cz, dmtrmonakhov@...dex-team.ru,
        dotdot@...dex-team.ru
Subject: [PATCH 2/2] ext4: export quota journalling mode via sysfs attr quota_mode

Right now, it is hard to understand what quota journalling type is enabled:
you need to be quite familiar with kernel code and trace it or really
understand what different combinations of fs flags/mount options lead to.

This patch exports via sysfs attr /sys/fs/ext4/<disk>/quota_mode current
quota jounalling mode, making it easier to check at a glance/in autotests.
The semantics is similar to ext4 data journalling modes:

* journalled - quota accounting and journaling are enabled
* writeback  - quota accounting is enabled, but journalling is disabled
* none       - quota accounting is disabled
* disabled   - kernel compiled without CONFIG_QUOTA feature

Signed-off-by: Roman Anufriev <dotdot@...dex-team.ru>
Reviewed-by: Dmitry Monakhov <dmtrmonakhov@...dex-team.ru>
---
 fs/ext4/sysfs.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c
index bfabb79..a46487f 100644
--- a/fs/ext4/sysfs.c
+++ b/fs/ext4/sysfs.c
@@ -36,6 +36,7 @@ typedef enum {
 	attr_pointer_string,
 	attr_pointer_atomic,
 	attr_journal_task,
+	attr_quota_mode,
 } attr_id_t;
 
 typedef enum {
@@ -140,6 +141,23 @@ static ssize_t journal_task_show(struct ext4_sb_info *sbi, char *buf)
 			task_pid_vnr(sbi->s_journal->j_task));
 }
 
+static ssize_t quota_mode_show(struct ext4_sb_info *sbi, char *buf)
+{
+#ifdef CONFIG_QUOTA
+	struct super_block *sb = sbi->s_buddy_cache->i_sb;
+
+	if (!ext4_any_quota_enabled(sb))
+		return snprintf(buf, PAGE_SIZE, "none\n");
+
+	if (ext4_is_quota_journalled(sb))
+		return snprintf(buf, PAGE_SIZE, "journalled\n");
+	else
+		return snprintf(buf, PAGE_SIZE, "writeback\n");
+#else
+	return snprintf(buf, PAGE_SIZE, "disabled\n");
+#endif
+}
+
 #define EXT4_ATTR(_name,_mode,_id)					\
 static struct ext4_attr ext4_attr_##_name = {				\
 	.attr = {.name = __stringify(_name), .mode = _mode },		\
@@ -248,6 +266,7 @@ EXT4_ATTR(last_error_time, 0444, last_error_time);
 EXT4_ATTR(journal_task, 0444, journal_task);
 EXT4_RW_ATTR_SBI_UI(mb_prefetch, s_mb_prefetch);
 EXT4_RW_ATTR_SBI_UI(mb_prefetch_limit, s_mb_prefetch_limit);
+EXT4_ATTR_FUNC(quota_mode, 0444);
 
 static unsigned int old_bump_val = 128;
 EXT4_ATTR_PTR(max_writeback_mb_bump, 0444, pointer_ui, &old_bump_val);
@@ -296,6 +315,7 @@ static struct attribute *ext4_attrs[] = {
 #endif
 	ATTR_LIST(mb_prefetch),
 	ATTR_LIST(mb_prefetch_limit),
+	ATTR_LIST(quota_mode),
 	NULL,
 };
 ATTRIBUTE_GROUPS(ext4);
@@ -425,6 +445,8 @@ static ssize_t ext4_attr_show(struct kobject *kobj,
 		return print_tstamp(buf, sbi->s_es, s_last_error_time);
 	case attr_journal_task:
 		return journal_task_show(sbi, buf);
+	case attr_quota_mode:
+		return quota_mode_show(sbi, buf);
 	}
 
 	return 0;
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ