License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 14:07:57 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2015-09-23 16:44:17 +00:00
|
|
|
/*
|
|
|
|
* linux/fs/ext4/sysfs.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 1992, 1993, 1994, 1995
|
|
|
|
* Remy Card (card@masi.ibp.fr)
|
|
|
|
* Theodore Ts'o (tytso@mit.edu)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/time.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/seq_file.h>
|
2018-01-11 20:11:32 +00:00
|
|
|
#include <linux/slab.h>
|
2015-09-23 16:44:17 +00:00
|
|
|
#include <linux/proc_fs.h>
|
2020-03-25 15:48:42 +00:00
|
|
|
#include <linux/part_stat.h>
|
2015-09-23 16:44:17 +00:00
|
|
|
|
|
|
|
#include "ext4.h"
|
|
|
|
#include "ext4_jbd2.h"
|
|
|
|
|
2015-09-23 16:45:17 +00:00
|
|
|
typedef enum {
|
|
|
|
attr_noop,
|
|
|
|
attr_delayed_allocation_blocks,
|
|
|
|
attr_session_write_kbytes,
|
|
|
|
attr_lifetime_write_kbytes,
|
|
|
|
attr_reserved_clusters,
|
2021-02-18 15:11:32 +00:00
|
|
|
attr_sra_exceeded_retry_limit,
|
2015-09-23 16:45:17 +00:00
|
|
|
attr_inode_readahead,
|
|
|
|
attr_trigger_test_error,
|
2018-07-29 19:51:48 +00:00
|
|
|
attr_first_error_time,
|
|
|
|
attr_last_error_time,
|
2015-09-23 16:45:17 +00:00
|
|
|
attr_feature,
|
|
|
|
attr_pointer_ui,
|
2019-11-21 18:09:43 +00:00
|
|
|
attr_pointer_ul,
|
2019-12-23 23:44:49 +00:00
|
|
|
attr_pointer_u64,
|
|
|
|
attr_pointer_u8,
|
|
|
|
attr_pointer_string,
|
2015-09-23 16:45:17 +00:00
|
|
|
attr_pointer_atomic,
|
2019-02-21 16:49:27 +00:00
|
|
|
attr_journal_task,
|
2015-09-23 16:45:17 +00:00
|
|
|
} attr_id_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
ptr_explicit,
|
|
|
|
ptr_ext4_sb_info_offset,
|
|
|
|
ptr_ext4_super_block_offset,
|
|
|
|
} attr_ptr_t;
|
|
|
|
|
2017-04-30 03:47:50 +00:00
|
|
|
static const char proc_dirname[] = "fs/ext4";
|
2015-09-23 16:46:17 +00:00
|
|
|
static struct proc_dir_entry *ext4_proc_root;
|
|
|
|
|
2015-09-23 16:44:17 +00:00
|
|
|
struct ext4_attr {
|
|
|
|
struct attribute attr;
|
2015-09-23 16:45:17 +00:00
|
|
|
short attr_id;
|
|
|
|
short attr_ptr;
|
2019-12-23 23:44:49 +00:00
|
|
|
unsigned short attr_size;
|
2015-09-23 16:44:17 +00:00
|
|
|
union {
|
|
|
|
int offset;
|
2015-09-23 16:45:17 +00:00
|
|
|
void *explicit_ptr;
|
2015-09-23 16:44:17 +00:00
|
|
|
} u;
|
|
|
|
};
|
|
|
|
|
2018-03-30 04:13:10 +00:00
|
|
|
static ssize_t session_write_kbytes_show(struct ext4_sb_info *sbi, char *buf)
|
2015-09-23 16:44:17 +00:00
|
|
|
{
|
|
|
|
struct super_block *sb = sbi->s_buddy_cache->i_sb;
|
|
|
|
|
2021-10-13 03:28:51 +00:00
|
|
|
return sysfs_emit(buf, "%lu\n",
|
2020-11-24 08:36:54 +00:00
|
|
|
(part_stat_read(sb->s_bdev, sectors[STAT_WRITE]) -
|
2015-09-23 16:44:17 +00:00
|
|
|
sbi->s_sectors_written_start) >> 1);
|
|
|
|
}
|
|
|
|
|
2018-03-30 04:13:10 +00:00
|
|
|
static ssize_t lifetime_write_kbytes_show(struct ext4_sb_info *sbi, char *buf)
|
2015-09-23 16:44:17 +00:00
|
|
|
{
|
|
|
|
struct super_block *sb = sbi->s_buddy_cache->i_sb;
|
|
|
|
|
2021-10-13 03:28:51 +00:00
|
|
|
return sysfs_emit(buf, "%llu\n",
|
2015-09-23 16:44:17 +00:00
|
|
|
(unsigned long long)(sbi->s_kbytes_written +
|
2020-11-24 08:36:54 +00:00
|
|
|
((part_stat_read(sb->s_bdev, sectors[STAT_WRITE]) -
|
2015-09-23 16:44:17 +00:00
|
|
|
EXT4_SB(sb)->s_sectors_written_start) >> 1)));
|
|
|
|
}
|
|
|
|
|
2018-03-30 04:13:10 +00:00
|
|
|
static ssize_t inode_readahead_blks_store(struct ext4_sb_info *sbi,
|
2015-09-23 16:44:17 +00:00
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
unsigned long t;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = kstrtoul(skip_spaces(buf), 0, &t);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if (t && (!is_power_of_2(t) || t > 0x40000000))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
sbi->s_inode_readahead_blks = t;
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2018-03-30 04:13:10 +00:00
|
|
|
static ssize_t reserved_clusters_store(struct ext4_sb_info *sbi,
|
2015-09-23 16:44:17 +00:00
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
unsigned long long val;
|
|
|
|
ext4_fsblk_t clusters = (ext4_blocks_count(sbi->s_es) >>
|
|
|
|
sbi->s_cluster_bits);
|
2015-09-23 16:45:17 +00:00
|
|
|
int ret;
|
2015-09-23 16:44:17 +00:00
|
|
|
|
2015-09-23 16:45:17 +00:00
|
|
|
ret = kstrtoull(skip_spaces(buf), 0, &val);
|
2017-06-23 05:08:22 +00:00
|
|
|
if (ret || val >= clusters)
|
2015-09-23 16:44:17 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
atomic64_set(&sbi->s_resv_clusters, val);
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2018-03-30 04:13:10 +00:00
|
|
|
static ssize_t trigger_test_error(struct ext4_sb_info *sbi,
|
2015-09-23 16:44:17 +00:00
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
int len = count;
|
|
|
|
|
|
|
|
if (!capable(CAP_SYS_ADMIN))
|
|
|
|
return -EPERM;
|
|
|
|
|
|
|
|
if (len && buf[len-1] == '\n')
|
|
|
|
len--;
|
|
|
|
|
|
|
|
if (len)
|
|
|
|
ext4_error(sbi->s_sb, "%.*s", len, buf);
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2019-02-21 16:49:27 +00:00
|
|
|
static ssize_t journal_task_show(struct ext4_sb_info *sbi, char *buf)
|
|
|
|
{
|
|
|
|
if (!sbi->s_journal)
|
2021-10-13 03:28:51 +00:00
|
|
|
return sysfs_emit(buf, "<none>\n");
|
|
|
|
return sysfs_emit(buf, "%d\n",
|
2019-02-21 16:49:27 +00:00
|
|
|
task_pid_vnr(sbi->s_journal->j_task));
|
|
|
|
}
|
|
|
|
|
2015-09-23 16:45:17 +00:00
|
|
|
#define EXT4_ATTR(_name,_mode,_id) \
|
|
|
|
static struct ext4_attr ext4_attr_##_name = { \
|
|
|
|
.attr = {.name = __stringify(_name), .mode = _mode }, \
|
|
|
|
.attr_id = attr_##_id, \
|
2015-09-23 16:44:17 +00:00
|
|
|
}
|
|
|
|
|
2015-09-23 16:45:17 +00:00
|
|
|
#define EXT4_ATTR_FUNC(_name,_mode) EXT4_ATTR(_name,_mode,_name)
|
|
|
|
|
|
|
|
#define EXT4_ATTR_FEATURE(_name) EXT4_ATTR(_name, 0444, feature)
|
|
|
|
|
|
|
|
#define EXT4_ATTR_OFFSET(_name,_mode,_id,_struct,_elname) \
|
2015-09-23 16:44:17 +00:00
|
|
|
static struct ext4_attr ext4_attr_##_name = { \
|
|
|
|
.attr = {.name = __stringify(_name), .mode = _mode }, \
|
2015-09-23 16:45:17 +00:00
|
|
|
.attr_id = attr_##_id, \
|
|
|
|
.attr_ptr = ptr_##_struct##_offset, \
|
2015-09-23 16:44:17 +00:00
|
|
|
.u = { \
|
2015-09-23 16:45:17 +00:00
|
|
|
.offset = offsetof(struct _struct, _elname),\
|
2015-09-23 16:44:17 +00:00
|
|
|
}, \
|
|
|
|
}
|
|
|
|
|
2019-12-23 23:44:49 +00:00
|
|
|
#define EXT4_ATTR_STRING(_name,_mode,_size,_struct,_elname) \
|
|
|
|
static struct ext4_attr ext4_attr_##_name = { \
|
|
|
|
.attr = {.name = __stringify(_name), .mode = _mode }, \
|
|
|
|
.attr_id = attr_pointer_string, \
|
|
|
|
.attr_size = _size, \
|
|
|
|
.attr_ptr = ptr_##_struct##_offset, \
|
|
|
|
.u = { \
|
|
|
|
.offset = offsetof(struct _struct, _elname),\
|
|
|
|
}, \
|
|
|
|
}
|
|
|
|
|
2015-09-23 16:45:17 +00:00
|
|
|
#define EXT4_RO_ATTR_ES_UI(_name,_elname) \
|
|
|
|
EXT4_ATTR_OFFSET(_name, 0444, pointer_ui, ext4_super_block, _elname)
|
2015-09-23 16:44:17 +00:00
|
|
|
|
2019-12-23 23:44:49 +00:00
|
|
|
#define EXT4_RO_ATTR_ES_U8(_name,_elname) \
|
|
|
|
EXT4_ATTR_OFFSET(_name, 0444, pointer_u8, ext4_super_block, _elname)
|
|
|
|
|
|
|
|
#define EXT4_RO_ATTR_ES_U64(_name,_elname) \
|
|
|
|
EXT4_ATTR_OFFSET(_name, 0444, pointer_u64, ext4_super_block, _elname)
|
|
|
|
|
|
|
|
#define EXT4_RO_ATTR_ES_STRING(_name,_elname,_size) \
|
|
|
|
EXT4_ATTR_STRING(_name, 0444, _size, ext4_super_block, _elname)
|
|
|
|
|
2015-09-23 16:45:17 +00:00
|
|
|
#define EXT4_RW_ATTR_SBI_UI(_name,_elname) \
|
|
|
|
EXT4_ATTR_OFFSET(_name, 0644, pointer_ui, ext4_sb_info, _elname)
|
2015-09-23 16:44:17 +00:00
|
|
|
|
2019-11-21 18:09:43 +00:00
|
|
|
#define EXT4_RW_ATTR_SBI_UL(_name,_elname) \
|
|
|
|
EXT4_ATTR_OFFSET(_name, 0644, pointer_ul, ext4_sb_info, _elname)
|
|
|
|
|
2020-07-25 12:33:13 +00:00
|
|
|
#define EXT4_RO_ATTR_SBI_ATOMIC(_name,_elname) \
|
|
|
|
EXT4_ATTR_OFFSET(_name, 0444, pointer_atomic, ext4_sb_info, _elname)
|
|
|
|
|
2015-09-23 16:45:17 +00:00
|
|
|
#define EXT4_ATTR_PTR(_name,_mode,_id,_ptr) \
|
2015-09-23 16:44:17 +00:00
|
|
|
static struct ext4_attr ext4_attr_##_name = { \
|
2015-09-23 16:45:17 +00:00
|
|
|
.attr = {.name = __stringify(_name), .mode = _mode }, \
|
|
|
|
.attr_id = attr_##_id, \
|
|
|
|
.attr_ptr = ptr_explicit, \
|
2015-09-23 16:44:17 +00:00
|
|
|
.u = { \
|
2015-09-23 16:45:17 +00:00
|
|
|
.explicit_ptr = _ptr, \
|
2015-09-23 16:44:17 +00:00
|
|
|
}, \
|
|
|
|
}
|
|
|
|
|
2015-09-23 16:45:17 +00:00
|
|
|
#define ATTR_LIST(name) &ext4_attr_##name.attr
|
|
|
|
|
|
|
|
EXT4_ATTR_FUNC(delayed_allocation_blocks, 0444);
|
|
|
|
EXT4_ATTR_FUNC(session_write_kbytes, 0444);
|
|
|
|
EXT4_ATTR_FUNC(lifetime_write_kbytes, 0444);
|
|
|
|
EXT4_ATTR_FUNC(reserved_clusters, 0644);
|
2021-02-18 15:11:32 +00:00
|
|
|
EXT4_ATTR_FUNC(sra_exceeded_retry_limit, 0444);
|
2015-09-23 16:45:17 +00:00
|
|
|
|
|
|
|
EXT4_ATTR_OFFSET(inode_readahead_blks, 0644, inode_readahead,
|
|
|
|
ext4_sb_info, s_inode_readahead_blks);
|
2015-09-23 16:44:17 +00:00
|
|
|
EXT4_RW_ATTR_SBI_UI(inode_goal, s_inode_goal);
|
|
|
|
EXT4_RW_ATTR_SBI_UI(mb_stats, s_mb_stats);
|
|
|
|
EXT4_RW_ATTR_SBI_UI(mb_max_to_scan, s_mb_max_to_scan);
|
|
|
|
EXT4_RW_ATTR_SBI_UI(mb_min_to_scan, s_mb_min_to_scan);
|
|
|
|
EXT4_RW_ATTR_SBI_UI(mb_order2_req, s_mb_order2_reqs);
|
|
|
|
EXT4_RW_ATTR_SBI_UI(mb_stream_req, s_mb_stream_request);
|
|
|
|
EXT4_RW_ATTR_SBI_UI(mb_group_prealloc, s_mb_group_prealloc);
|
2020-08-17 07:36:15 +00:00
|
|
|
EXT4_RW_ATTR_SBI_UI(mb_max_inode_prealloc, s_mb_max_inode_prealloc);
|
ext4: improve cr 0 / cr 1 group scanning
Instead of traversing through groups linearly, scan groups in specific
orders at cr 0 and cr 1. At cr 0, we want to find groups that have the
largest free order >= the order of the request. So, with this patch,
we maintain lists for each possible order and insert each group into a
list based on the largest free order in its buddy bitmap. During cr 0
allocation, we traverse these lists in the increasing order of largest
free orders. This allows us to find a group with the best available cr
0 match in constant time. If nothing can be found, we fallback to cr 1
immediately.
At CR1, the story is slightly different. We want to traverse in the
order of increasing average fragment size. For CR1, we maintain a rb
tree of groupinfos which is sorted by average fragment size. Instead
of traversing linearly, at CR1, we traverse in the order of increasing
average fragment size, starting at the most optimal group. This brings
down cr 1 search complexity to log(num groups).
For cr >= 2, we just perform the linear search as before. Also, in
case of lock contention, we intermittently fallback to linear search
even in CR 0 and CR 1 cases. This allows us to proceed during the
allocation path even in case of high contention.
There is an opportunity to do optimization at CR2 too. That's because
at CR2 we only consider groups where bb_free counter (number of free
blocks) is greater than the request extent size. That's left as future
work.
All the changes introduced in this patch are protected under a new
mount option "mb_optimize_scan".
With this patchset, following experiment was performed:
Created a highly fragmented disk of size 65TB. The disk had no
contiguous 2M regions. Following command was run consecutively for 3
times:
time dd if=/dev/urandom of=file bs=2M count=10
Here are the results with and without cr 0/1 optimizations introduced
in this patch:
|---------+------------------------------+---------------------------|
| | Without CR 0/1 Optimizations | With CR 0/1 Optimizations |
|---------+------------------------------+---------------------------|
| 1st run | 5m1.871s | 2m47.642s |
| 2nd run | 2m28.390s | 0m0.611s |
| 3rd run | 2m26.530s | 0m1.255s |
|---------+------------------------------+---------------------------|
Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Link: https://lore.kernel.org/r/20210401172129.189766-6-harshadshirwadkar@gmail.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-04-01 17:21:27 +00:00
|
|
|
EXT4_RW_ATTR_SBI_UI(mb_max_linear_groups, s_mb_max_linear_groups);
|
2015-09-23 16:44:17 +00:00
|
|
|
EXT4_RW_ATTR_SBI_UI(extent_max_zeroout_kb, s_extent_max_zeroout_kb);
|
2015-09-23 16:45:17 +00:00
|
|
|
EXT4_ATTR(trigger_fs_error, 0200, trigger_test_error);
|
2015-09-23 16:44:17 +00:00
|
|
|
EXT4_RW_ATTR_SBI_UI(err_ratelimit_interval_ms, s_err_ratelimit_state.interval);
|
|
|
|
EXT4_RW_ATTR_SBI_UI(err_ratelimit_burst, s_err_ratelimit_state.burst);
|
|
|
|
EXT4_RW_ATTR_SBI_UI(warning_ratelimit_interval_ms, s_warning_ratelimit_state.interval);
|
|
|
|
EXT4_RW_ATTR_SBI_UI(warning_ratelimit_burst, s_warning_ratelimit_state.burst);
|
|
|
|
EXT4_RW_ATTR_SBI_UI(msg_ratelimit_interval_ms, s_msg_ratelimit_state.interval);
|
|
|
|
EXT4_RW_ATTR_SBI_UI(msg_ratelimit_burst, s_msg_ratelimit_state.burst);
|
2019-11-21 18:09:43 +00:00
|
|
|
#ifdef CONFIG_EXT4_DEBUG
|
|
|
|
EXT4_RW_ATTR_SBI_UL(simulate_fail, s_simulate_fail);
|
|
|
|
#endif
|
2020-07-25 12:33:13 +00:00
|
|
|
EXT4_RO_ATTR_SBI_ATOMIC(warning_count, s_warning_count);
|
|
|
|
EXT4_RO_ATTR_SBI_ATOMIC(msg_count, s_msg_count);
|
2015-09-23 16:44:17 +00:00
|
|
|
EXT4_RO_ATTR_ES_UI(errors_count, s_error_count);
|
2019-12-23 23:44:49 +00:00
|
|
|
EXT4_RO_ATTR_ES_U8(first_error_errcode, s_first_error_errcode);
|
|
|
|
EXT4_RO_ATTR_ES_U8(last_error_errcode, s_last_error_errcode);
|
|
|
|
EXT4_RO_ATTR_ES_UI(first_error_ino, s_first_error_ino);
|
|
|
|
EXT4_RO_ATTR_ES_UI(last_error_ino, s_last_error_ino);
|
|
|
|
EXT4_RO_ATTR_ES_U64(first_error_block, s_first_error_block);
|
|
|
|
EXT4_RO_ATTR_ES_U64(last_error_block, s_last_error_block);
|
|
|
|
EXT4_RO_ATTR_ES_UI(first_error_line, s_first_error_line);
|
|
|
|
EXT4_RO_ATTR_ES_UI(last_error_line, s_last_error_line);
|
|
|
|
EXT4_RO_ATTR_ES_STRING(first_error_func, s_first_error_func, 32);
|
|
|
|
EXT4_RO_ATTR_ES_STRING(last_error_func, s_last_error_func, 32);
|
2018-07-29 19:51:48 +00:00
|
|
|
EXT4_ATTR(first_error_time, 0444, first_error_time);
|
|
|
|
EXT4_ATTR(last_error_time, 0444, last_error_time);
|
2019-02-21 16:49:27 +00:00
|
|
|
EXT4_ATTR(journal_task, 0444, journal_task);
|
2020-04-21 07:54:07 +00:00
|
|
|
EXT4_RW_ATTR_SBI_UI(mb_prefetch, s_mb_prefetch);
|
|
|
|
EXT4_RW_ATTR_SBI_UI(mb_prefetch_limit, s_mb_prefetch_limit);
|
2021-11-03 14:51:22 +00:00
|
|
|
EXT4_RW_ATTR_SBI_UL(last_trim_minblks, s_last_trim_minblks);
|
2015-09-23 16:44:17 +00:00
|
|
|
|
2015-09-23 16:45:17 +00:00
|
|
|
static unsigned int old_bump_val = 128;
|
|
|
|
EXT4_ATTR_PTR(max_writeback_mb_bump, 0444, pointer_ui, &old_bump_val);
|
|
|
|
|
2015-09-23 16:44:17 +00:00
|
|
|
static struct attribute *ext4_attrs[] = {
|
|
|
|
ATTR_LIST(delayed_allocation_blocks),
|
|
|
|
ATTR_LIST(session_write_kbytes),
|
|
|
|
ATTR_LIST(lifetime_write_kbytes),
|
|
|
|
ATTR_LIST(reserved_clusters),
|
2021-02-18 15:11:32 +00:00
|
|
|
ATTR_LIST(sra_exceeded_retry_limit),
|
2015-09-23 16:44:17 +00:00
|
|
|
ATTR_LIST(inode_readahead_blks),
|
|
|
|
ATTR_LIST(inode_goal),
|
|
|
|
ATTR_LIST(mb_stats),
|
|
|
|
ATTR_LIST(mb_max_to_scan),
|
|
|
|
ATTR_LIST(mb_min_to_scan),
|
|
|
|
ATTR_LIST(mb_order2_req),
|
|
|
|
ATTR_LIST(mb_stream_req),
|
|
|
|
ATTR_LIST(mb_group_prealloc),
|
2020-08-17 07:36:15 +00:00
|
|
|
ATTR_LIST(mb_max_inode_prealloc),
|
ext4: improve cr 0 / cr 1 group scanning
Instead of traversing through groups linearly, scan groups in specific
orders at cr 0 and cr 1. At cr 0, we want to find groups that have the
largest free order >= the order of the request. So, with this patch,
we maintain lists for each possible order and insert each group into a
list based on the largest free order in its buddy bitmap. During cr 0
allocation, we traverse these lists in the increasing order of largest
free orders. This allows us to find a group with the best available cr
0 match in constant time. If nothing can be found, we fallback to cr 1
immediately.
At CR1, the story is slightly different. We want to traverse in the
order of increasing average fragment size. For CR1, we maintain a rb
tree of groupinfos which is sorted by average fragment size. Instead
of traversing linearly, at CR1, we traverse in the order of increasing
average fragment size, starting at the most optimal group. This brings
down cr 1 search complexity to log(num groups).
For cr >= 2, we just perform the linear search as before. Also, in
case of lock contention, we intermittently fallback to linear search
even in CR 0 and CR 1 cases. This allows us to proceed during the
allocation path even in case of high contention.
There is an opportunity to do optimization at CR2 too. That's because
at CR2 we only consider groups where bb_free counter (number of free
blocks) is greater than the request extent size. That's left as future
work.
All the changes introduced in this patch are protected under a new
mount option "mb_optimize_scan".
With this patchset, following experiment was performed:
Created a highly fragmented disk of size 65TB. The disk had no
contiguous 2M regions. Following command was run consecutively for 3
times:
time dd if=/dev/urandom of=file bs=2M count=10
Here are the results with and without cr 0/1 optimizations introduced
in this patch:
|---------+------------------------------+---------------------------|
| | Without CR 0/1 Optimizations | With CR 0/1 Optimizations |
|---------+------------------------------+---------------------------|
| 1st run | 5m1.871s | 2m47.642s |
| 2nd run | 2m28.390s | 0m0.611s |
| 3rd run | 2m26.530s | 0m1.255s |
|---------+------------------------------+---------------------------|
Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Link: https://lore.kernel.org/r/20210401172129.189766-6-harshadshirwadkar@gmail.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2021-04-01 17:21:27 +00:00
|
|
|
ATTR_LIST(mb_max_linear_groups),
|
2015-09-23 16:44:17 +00:00
|
|
|
ATTR_LIST(max_writeback_mb_bump),
|
|
|
|
ATTR_LIST(extent_max_zeroout_kb),
|
|
|
|
ATTR_LIST(trigger_fs_error),
|
|
|
|
ATTR_LIST(err_ratelimit_interval_ms),
|
|
|
|
ATTR_LIST(err_ratelimit_burst),
|
|
|
|
ATTR_LIST(warning_ratelimit_interval_ms),
|
|
|
|
ATTR_LIST(warning_ratelimit_burst),
|
|
|
|
ATTR_LIST(msg_ratelimit_interval_ms),
|
|
|
|
ATTR_LIST(msg_ratelimit_burst),
|
|
|
|
ATTR_LIST(errors_count),
|
2020-07-25 12:33:13 +00:00
|
|
|
ATTR_LIST(warning_count),
|
|
|
|
ATTR_LIST(msg_count),
|
2019-12-23 23:44:49 +00:00
|
|
|
ATTR_LIST(first_error_ino),
|
|
|
|
ATTR_LIST(last_error_ino),
|
|
|
|
ATTR_LIST(first_error_block),
|
|
|
|
ATTR_LIST(last_error_block),
|
|
|
|
ATTR_LIST(first_error_line),
|
|
|
|
ATTR_LIST(last_error_line),
|
|
|
|
ATTR_LIST(first_error_func),
|
|
|
|
ATTR_LIST(last_error_func),
|
|
|
|
ATTR_LIST(first_error_errcode),
|
|
|
|
ATTR_LIST(last_error_errcode),
|
2015-09-23 16:44:17 +00:00
|
|
|
ATTR_LIST(first_error_time),
|
|
|
|
ATTR_LIST(last_error_time),
|
2019-02-21 16:49:27 +00:00
|
|
|
ATTR_LIST(journal_task),
|
2019-11-21 18:09:43 +00:00
|
|
|
#ifdef CONFIG_EXT4_DEBUG
|
|
|
|
ATTR_LIST(simulate_fail),
|
|
|
|
#endif
|
2020-04-21 07:54:07 +00:00
|
|
|
ATTR_LIST(mb_prefetch),
|
|
|
|
ATTR_LIST(mb_prefetch_limit),
|
2021-11-03 14:51:22 +00:00
|
|
|
ATTR_LIST(last_trim_minblks),
|
2015-09-23 16:44:17 +00:00
|
|
|
NULL,
|
|
|
|
};
|
2019-07-02 21:38:55 +00:00
|
|
|
ATTRIBUTE_GROUPS(ext4);
|
2015-09-23 16:44:17 +00:00
|
|
|
|
|
|
|
/* Features this copy of ext4 supports */
|
2015-09-23 16:45:17 +00:00
|
|
|
EXT4_ATTR_FEATURE(lazy_itable_init);
|
|
|
|
EXT4_ATTR_FEATURE(batched_discard);
|
|
|
|
EXT4_ATTR_FEATURE(meta_bg_resize);
|
2018-12-12 09:50:12 +00:00
|
|
|
#ifdef CONFIG_FS_ENCRYPTION
|
2015-09-23 16:45:17 +00:00
|
|
|
EXT4_ATTR_FEATURE(encryption);
|
fscrypt: support test_dummy_encryption=v2
v1 encryption policies are deprecated in favor of v2, and some new
features (e.g. encryption+casefolding) are only being added for v2.
Therefore, the "test_dummy_encryption" mount option (which is used for
encryption I/O testing with xfstests) needs to support v2 policies.
To do this, extend its syntax to be "test_dummy_encryption=v1" or
"test_dummy_encryption=v2". The existing "test_dummy_encryption" (no
argument) also continues to be accepted, to specify the default setting
-- currently v1, but the next patch changes it to v2.
To cleanly support both v1 and v2 while also making it easy to support
specifying other encryption settings in the future (say, accepting
"$contents_mode:$filenames_mode:v2"), make ext4 and f2fs maintain a
pointer to the dummy fscrypt_context rather than using mount flags.
To avoid concurrency issues, don't allow test_dummy_encryption to be set
or changed during a remount. (The former restriction is new, but
xfstests doesn't run into it, so no one should notice.)
Tested with 'gce-xfstests -c {ext4,f2fs}/encrypt -g auto'. On ext4,
there are two regressions, both of which are test bugs: ext4/023 and
ext4/028 fail because they set an xattr and expect it to be stored
inline, but the increase in size of the fscrypt_context from
24 to 40 bytes causes this xattr to be spilled into an external block.
Link: https://lore.kernel.org/r/20200512233251.118314-4-ebiggers@kernel.org
Acked-by: Jaegeuk Kim <jaegeuk@kernel.org>
Reviewed-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Eric Biggers <ebiggers@google.com>
2020-05-12 23:32:50 +00:00
|
|
|
EXT4_ATTR_FEATURE(test_dummy_encryption_v2);
|
2016-10-13 03:24:51 +00:00
|
|
|
#endif
|
2022-01-18 06:56:14 +00:00
|
|
|
#if IS_ENABLED(CONFIG_UNICODE)
|
2019-05-06 18:03:52 +00:00
|
|
|
EXT4_ATTR_FEATURE(casefold);
|
|
|
|
#endif
|
2019-07-22 16:26:24 +00:00
|
|
|
#ifdef CONFIG_FS_VERITY
|
|
|
|
EXT4_ATTR_FEATURE(verity);
|
|
|
|
#endif
|
2015-10-17 20:16:02 +00:00
|
|
|
EXT4_ATTR_FEATURE(metadata_csum_seed);
|
2020-10-28 17:39:13 +00:00
|
|
|
EXT4_ATTR_FEATURE(fast_commit);
|
2022-01-18 06:56:14 +00:00
|
|
|
#if IS_ENABLED(CONFIG_UNICODE) && defined(CONFIG_FS_ENCRYPTION)
|
2021-03-19 07:34:13 +00:00
|
|
|
EXT4_ATTR_FEATURE(encrypted_casefold);
|
2021-06-03 09:48:49 +00:00
|
|
|
#endif
|
2015-09-23 16:44:17 +00:00
|
|
|
|
|
|
|
static struct attribute *ext4_feat_attrs[] = {
|
|
|
|
ATTR_LIST(lazy_itable_init),
|
|
|
|
ATTR_LIST(batched_discard),
|
|
|
|
ATTR_LIST(meta_bg_resize),
|
2018-12-12 09:50:12 +00:00
|
|
|
#ifdef CONFIG_FS_ENCRYPTION
|
2015-09-23 16:44:17 +00:00
|
|
|
ATTR_LIST(encryption),
|
fscrypt: support test_dummy_encryption=v2
v1 encryption policies are deprecated in favor of v2, and some new
features (e.g. encryption+casefolding) are only being added for v2.
Therefore, the "test_dummy_encryption" mount option (which is used for
encryption I/O testing with xfstests) needs to support v2 policies.
To do this, extend its syntax to be "test_dummy_encryption=v1" or
"test_dummy_encryption=v2". The existing "test_dummy_encryption" (no
argument) also continues to be accepted, to specify the default setting
-- currently v1, but the next patch changes it to v2.
To cleanly support both v1 and v2 while also making it easy to support
specifying other encryption settings in the future (say, accepting
"$contents_mode:$filenames_mode:v2"), make ext4 and f2fs maintain a
pointer to the dummy fscrypt_context rather than using mount flags.
To avoid concurrency issues, don't allow test_dummy_encryption to be set
or changed during a remount. (The former restriction is new, but
xfstests doesn't run into it, so no one should notice.)
Tested with 'gce-xfstests -c {ext4,f2fs}/encrypt -g auto'. On ext4,
there are two regressions, both of which are test bugs: ext4/023 and
ext4/028 fail because they set an xattr and expect it to be stored
inline, but the increase in size of the fscrypt_context from
24 to 40 bytes causes this xattr to be spilled into an external block.
Link: https://lore.kernel.org/r/20200512233251.118314-4-ebiggers@kernel.org
Acked-by: Jaegeuk Kim <jaegeuk@kernel.org>
Reviewed-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Eric Biggers <ebiggers@google.com>
2020-05-12 23:32:50 +00:00
|
|
|
ATTR_LIST(test_dummy_encryption_v2),
|
2019-05-06 18:03:52 +00:00
|
|
|
#endif
|
2022-01-18 06:56:14 +00:00
|
|
|
#if IS_ENABLED(CONFIG_UNICODE)
|
2019-05-06 18:03:52 +00:00
|
|
|
ATTR_LIST(casefold),
|
2019-07-22 16:26:24 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_FS_VERITY
|
|
|
|
ATTR_LIST(verity),
|
2016-10-13 03:24:51 +00:00
|
|
|
#endif
|
2015-10-17 20:16:02 +00:00
|
|
|
ATTR_LIST(metadata_csum_seed),
|
2020-10-28 17:39:13 +00:00
|
|
|
ATTR_LIST(fast_commit),
|
2022-01-18 06:56:14 +00:00
|
|
|
#if IS_ENABLED(CONFIG_UNICODE) && defined(CONFIG_FS_ENCRYPTION)
|
2021-03-19 07:34:13 +00:00
|
|
|
ATTR_LIST(encrypted_casefold),
|
2021-06-03 09:48:49 +00:00
|
|
|
#endif
|
2015-09-23 16:44:17 +00:00
|
|
|
NULL,
|
|
|
|
};
|
2019-07-02 21:38:55 +00:00
|
|
|
ATTRIBUTE_GROUPS(ext4_feat);
|
2015-09-23 16:44:17 +00:00
|
|
|
|
2015-09-23 16:45:17 +00:00
|
|
|
static void *calc_ptr(struct ext4_attr *a, struct ext4_sb_info *sbi)
|
|
|
|
{
|
|
|
|
switch (a->attr_ptr) {
|
|
|
|
case ptr_explicit:
|
|
|
|
return a->u.explicit_ptr;
|
|
|
|
case ptr_ext4_sb_info_offset:
|
|
|
|
return (void *) (((char *) sbi) + a->u.offset);
|
|
|
|
case ptr_ext4_super_block_offset:
|
|
|
|
return (void *) (((char *) sbi->s_es) + a->u.offset);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-07-29 19:51:48 +00:00
|
|
|
static ssize_t __print_tstamp(char *buf, __le32 lo, __u8 hi)
|
|
|
|
{
|
2021-10-13 03:28:51 +00:00
|
|
|
return sysfs_emit(buf, "%lld\n",
|
2018-07-29 19:51:48 +00:00
|
|
|
((time64_t)hi << 32) + le32_to_cpu(lo));
|
|
|
|
}
|
|
|
|
|
|
|
|
#define print_tstamp(buf, es, tstamp) \
|
|
|
|
__print_tstamp(buf, (es)->tstamp, (es)->tstamp ## _hi)
|
|
|
|
|
2015-09-23 16:44:17 +00:00
|
|
|
static ssize_t ext4_attr_show(struct kobject *kobj,
|
|
|
|
struct attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct ext4_sb_info *sbi = container_of(kobj, struct ext4_sb_info,
|
|
|
|
s_kobj);
|
|
|
|
struct ext4_attr *a = container_of(attr, struct ext4_attr, attr);
|
2015-09-23 16:45:17 +00:00
|
|
|
void *ptr = calc_ptr(a, sbi);
|
|
|
|
|
|
|
|
switch (a->attr_id) {
|
|
|
|
case attr_delayed_allocation_blocks:
|
2021-10-13 03:28:51 +00:00
|
|
|
return sysfs_emit(buf, "%llu\n",
|
2015-09-23 16:45:17 +00:00
|
|
|
(s64) EXT4_C2B(sbi,
|
|
|
|
percpu_counter_sum(&sbi->s_dirtyclusters_counter)));
|
|
|
|
case attr_session_write_kbytes:
|
2018-03-30 04:13:10 +00:00
|
|
|
return session_write_kbytes_show(sbi, buf);
|
2015-09-23 16:45:17 +00:00
|
|
|
case attr_lifetime_write_kbytes:
|
2018-03-30 04:13:10 +00:00
|
|
|
return lifetime_write_kbytes_show(sbi, buf);
|
2015-09-23 16:45:17 +00:00
|
|
|
case attr_reserved_clusters:
|
2021-10-13 03:28:51 +00:00
|
|
|
return sysfs_emit(buf, "%llu\n",
|
2015-09-23 16:45:17 +00:00
|
|
|
(unsigned long long)
|
|
|
|
atomic64_read(&sbi->s_resv_clusters));
|
2021-02-18 15:11:32 +00:00
|
|
|
case attr_sra_exceeded_retry_limit:
|
2021-10-13 03:28:51 +00:00
|
|
|
return sysfs_emit(buf, "%llu\n",
|
2021-02-18 15:11:32 +00:00
|
|
|
(unsigned long long)
|
|
|
|
percpu_counter_sum(&sbi->s_sra_exceeded_retry_limit));
|
2015-09-23 16:45:17 +00:00
|
|
|
case attr_inode_readahead:
|
|
|
|
case attr_pointer_ui:
|
|
|
|
if (!ptr)
|
|
|
|
return 0;
|
2018-07-29 19:48:00 +00:00
|
|
|
if (a->attr_ptr == ptr_ext4_super_block_offset)
|
2021-10-13 03:28:51 +00:00
|
|
|
return sysfs_emit(buf, "%u\n",
|
2018-07-29 19:48:00 +00:00
|
|
|
le32_to_cpup(ptr));
|
|
|
|
else
|
2021-10-13 03:28:51 +00:00
|
|
|
return sysfs_emit(buf, "%u\n",
|
2018-07-29 19:48:00 +00:00
|
|
|
*((unsigned int *) ptr));
|
2019-11-21 18:09:43 +00:00
|
|
|
case attr_pointer_ul:
|
|
|
|
if (!ptr)
|
|
|
|
return 0;
|
2021-10-13 03:28:51 +00:00
|
|
|
return sysfs_emit(buf, "%lu\n",
|
2019-11-21 18:09:43 +00:00
|
|
|
*((unsigned long *) ptr));
|
2019-12-23 23:44:49 +00:00
|
|
|
case attr_pointer_u8:
|
|
|
|
if (!ptr)
|
|
|
|
return 0;
|
2021-10-13 03:28:51 +00:00
|
|
|
return sysfs_emit(buf, "%u\n",
|
2019-12-23 23:44:49 +00:00
|
|
|
*((unsigned char *) ptr));
|
|
|
|
case attr_pointer_u64:
|
|
|
|
if (!ptr)
|
|
|
|
return 0;
|
|
|
|
if (a->attr_ptr == ptr_ext4_super_block_offset)
|
2021-10-13 03:28:51 +00:00
|
|
|
return sysfs_emit(buf, "%llu\n",
|
2019-12-23 23:44:49 +00:00
|
|
|
le64_to_cpup(ptr));
|
|
|
|
else
|
2021-10-13 03:28:51 +00:00
|
|
|
return sysfs_emit(buf, "%llu\n",
|
2019-12-23 23:44:49 +00:00
|
|
|
*((unsigned long long *) ptr));
|
|
|
|
case attr_pointer_string:
|
|
|
|
if (!ptr)
|
|
|
|
return 0;
|
2021-10-13 03:28:51 +00:00
|
|
|
return sysfs_emit(buf, "%.*s\n", a->attr_size,
|
2019-12-23 23:44:49 +00:00
|
|
|
(char *) ptr);
|
2015-09-23 16:45:17 +00:00
|
|
|
case attr_pointer_atomic:
|
|
|
|
if (!ptr)
|
|
|
|
return 0;
|
2021-10-13 03:28:51 +00:00
|
|
|
return sysfs_emit(buf, "%d\n",
|
2015-09-23 16:45:17 +00:00
|
|
|
atomic_read((atomic_t *) ptr));
|
|
|
|
case attr_feature:
|
2021-10-13 03:28:51 +00:00
|
|
|
return sysfs_emit(buf, "supported\n");
|
2018-07-29 19:51:48 +00:00
|
|
|
case attr_first_error_time:
|
|
|
|
return print_tstamp(buf, sbi->s_es, s_first_error_time);
|
|
|
|
case attr_last_error_time:
|
|
|
|
return print_tstamp(buf, sbi->s_es, s_last_error_time);
|
2019-02-21 16:49:27 +00:00
|
|
|
case attr_journal_task:
|
|
|
|
return journal_task_show(sbi, buf);
|
2015-09-23 16:45:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2015-09-23 16:44:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t ext4_attr_store(struct kobject *kobj,
|
|
|
|
struct attribute *attr,
|
|
|
|
const char *buf, size_t len)
|
|
|
|
{
|
|
|
|
struct ext4_sb_info *sbi = container_of(kobj, struct ext4_sb_info,
|
|
|
|
s_kobj);
|
|
|
|
struct ext4_attr *a = container_of(attr, struct ext4_attr, attr);
|
2015-09-23 16:45:17 +00:00
|
|
|
void *ptr = calc_ptr(a, sbi);
|
|
|
|
unsigned long t;
|
|
|
|
int ret;
|
2015-09-23 16:44:17 +00:00
|
|
|
|
2015-09-23 16:45:17 +00:00
|
|
|
switch (a->attr_id) {
|
|
|
|
case attr_reserved_clusters:
|
2018-03-30 04:13:10 +00:00
|
|
|
return reserved_clusters_store(sbi, buf, len);
|
2015-09-23 16:45:17 +00:00
|
|
|
case attr_pointer_ui:
|
|
|
|
if (!ptr)
|
|
|
|
return 0;
|
|
|
|
ret = kstrtoul(skip_spaces(buf), 0, &t);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2018-07-29 19:48:00 +00:00
|
|
|
if (a->attr_ptr == ptr_ext4_super_block_offset)
|
|
|
|
*((__le32 *) ptr) = cpu_to_le32(t);
|
|
|
|
else
|
|
|
|
*((unsigned int *) ptr) = t;
|
2015-09-23 16:45:17 +00:00
|
|
|
return len;
|
2019-11-21 18:09:43 +00:00
|
|
|
case attr_pointer_ul:
|
|
|
|
if (!ptr)
|
|
|
|
return 0;
|
|
|
|
ret = kstrtoul(skip_spaces(buf), 0, &t);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
*((unsigned long *) ptr) = t;
|
|
|
|
return len;
|
2015-09-23 16:45:17 +00:00
|
|
|
case attr_inode_readahead:
|
2018-03-30 04:13:10 +00:00
|
|
|
return inode_readahead_blks_store(sbi, buf, len);
|
2015-09-23 16:45:17 +00:00
|
|
|
case attr_trigger_test_error:
|
2018-03-30 04:13:10 +00:00
|
|
|
return trigger_test_error(sbi, buf, len);
|
2015-09-23 16:45:17 +00:00
|
|
|
}
|
|
|
|
return 0;
|
2015-09-23 16:44:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ext4_sb_release(struct kobject *kobj)
|
|
|
|
{
|
|
|
|
struct ext4_sb_info *sbi = container_of(kobj, struct ext4_sb_info,
|
|
|
|
s_kobj);
|
|
|
|
complete(&sbi->s_kobj_unregister);
|
|
|
|
}
|
|
|
|
|
2023-01-04 21:09:12 +00:00
|
|
|
static void ext4_feat_release(struct kobject *kobj)
|
|
|
|
{
|
|
|
|
kfree(kobj);
|
|
|
|
}
|
|
|
|
|
2015-09-23 16:44:17 +00:00
|
|
|
static const struct sysfs_ops ext4_attr_ops = {
|
|
|
|
.show = ext4_attr_show,
|
|
|
|
.store = ext4_attr_store,
|
|
|
|
};
|
|
|
|
|
2023-02-09 03:18:35 +00:00
|
|
|
static const struct kobj_type ext4_sb_ktype = {
|
2019-07-02 21:38:55 +00:00
|
|
|
.default_groups = ext4_groups,
|
2015-09-23 16:44:17 +00:00
|
|
|
.sysfs_ops = &ext4_attr_ops,
|
|
|
|
.release = ext4_sb_release,
|
|
|
|
};
|
|
|
|
|
2023-02-09 03:18:35 +00:00
|
|
|
static const struct kobj_type ext4_feat_ktype = {
|
2019-07-02 21:38:55 +00:00
|
|
|
.default_groups = ext4_feat_groups,
|
2015-09-23 16:45:17 +00:00
|
|
|
.sysfs_ops = &ext4_attr_ops,
|
2023-01-04 21:09:12 +00:00
|
|
|
.release = ext4_feat_release,
|
2015-09-23 16:44:17 +00:00
|
|
|
};
|
|
|
|
|
2021-06-11 14:02:08 +00:00
|
|
|
void ext4_notify_error_sysfs(struct ext4_sb_info *sbi)
|
|
|
|
{
|
|
|
|
sysfs_notify(&sbi->s_kobj, NULL, "errors_count");
|
|
|
|
}
|
|
|
|
|
2018-03-30 04:41:34 +00:00
|
|
|
static struct kobject *ext4_root;
|
|
|
|
|
2018-01-11 20:11:32 +00:00
|
|
|
static struct kobject *ext4_feat;
|
2015-09-23 16:44:17 +00:00
|
|
|
|
|
|
|
int ext4_register_sysfs(struct super_block *sb)
|
|
|
|
{
|
|
|
|
struct ext4_sb_info *sbi = EXT4_SB(sb);
|
2015-09-23 16:46:17 +00:00
|
|
|
int err;
|
2015-09-23 16:44:17 +00:00
|
|
|
|
|
|
|
init_completion(&sbi->s_kobj_unregister);
|
2018-03-30 04:41:34 +00:00
|
|
|
err = kobject_init_and_add(&sbi->s_kobj, &ext4_sb_ktype, ext4_root,
|
2015-09-23 16:46:17 +00:00
|
|
|
"%s", sb->s_id);
|
2018-01-11 19:28:13 +00:00
|
|
|
if (err) {
|
|
|
|
kobject_put(&sbi->s_kobj);
|
|
|
|
wait_for_completion(&sbi->s_kobj_unregister);
|
2015-09-23 16:46:17 +00:00
|
|
|
return err;
|
2018-01-11 19:28:13 +00:00
|
|
|
}
|
2015-09-23 16:46:17 +00:00
|
|
|
|
|
|
|
if (ext4_proc_root)
|
|
|
|
sbi->s_proc = proc_mkdir(sb->s_id, ext4_proc_root);
|
|
|
|
if (sbi->s_proc) {
|
2018-04-11 09:37:23 +00:00
|
|
|
proc_create_single_data("options", S_IRUGO, sbi->s_proc,
|
|
|
|
ext4_seq_options_show, sb);
|
|
|
|
proc_create_single_data("es_shrinker_info", S_IRUGO,
|
|
|
|
sbi->s_proc, ext4_seq_es_shrinker_info_show,
|
|
|
|
sb);
|
2020-10-15 20:38:01 +00:00
|
|
|
proc_create_single_data("fc_info", 0444, sbi->s_proc,
|
|
|
|
ext4_fc_info_show, sb);
|
2018-04-11 09:37:23 +00:00
|
|
|
proc_create_seq_data("mb_groups", S_IRUGO, sbi->s_proc,
|
|
|
|
&ext4_mb_seq_groups_ops, sb);
|
2021-04-01 17:21:25 +00:00
|
|
|
proc_create_single_data("mb_stats", 0444, sbi->s_proc,
|
|
|
|
ext4_seq_mb_stats_show, sb);
|
2021-04-01 17:21:28 +00:00
|
|
|
proc_create_seq_data("mb_structs_summary", 0444, sbi->s_proc,
|
|
|
|
&ext4_mb_seq_structs_summary_ops, sb);
|
2015-09-23 16:46:17 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ext4_unregister_sysfs(struct super_block *sb)
|
|
|
|
{
|
|
|
|
struct ext4_sb_info *sbi = EXT4_SB(sb);
|
|
|
|
|
2018-04-11 09:37:23 +00:00
|
|
|
if (sbi->s_proc)
|
|
|
|
remove_proc_subtree(sb->s_id, ext4_proc_root);
|
2015-09-23 16:46:17 +00:00
|
|
|
kobject_del(&sbi->s_kobj);
|
2015-09-23 16:44:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int __init ext4_init_sysfs(void)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2018-03-30 04:41:34 +00:00
|
|
|
ext4_root = kobject_create_and_add("ext4", fs_kobj);
|
|
|
|
if (!ext4_root)
|
2018-01-11 20:34:04 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
|
2018-01-11 20:11:32 +00:00
|
|
|
ext4_feat = kzalloc(sizeof(*ext4_feat), GFP_KERNEL);
|
|
|
|
if (!ext4_feat) {
|
|
|
|
ret = -ENOMEM;
|
2018-03-30 04:41:34 +00:00
|
|
|
goto root_err;
|
2018-01-11 19:28:13 +00:00
|
|
|
}
|
2018-01-11 20:11:32 +00:00
|
|
|
|
|
|
|
ret = kobject_init_and_add(ext4_feat, &ext4_feat_ktype,
|
2018-03-30 04:41:34 +00:00
|
|
|
ext4_root, "features");
|
2018-01-11 20:11:32 +00:00
|
|
|
if (ret)
|
|
|
|
goto feat_err;
|
|
|
|
|
|
|
|
ext4_proc_root = proc_mkdir(proc_dirname, NULL);
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
feat_err:
|
|
|
|
kobject_put(ext4_feat);
|
2018-03-30 04:03:38 +00:00
|
|
|
ext4_feat = NULL;
|
2018-03-30 04:41:34 +00:00
|
|
|
root_err:
|
|
|
|
kobject_put(ext4_root);
|
|
|
|
ext4_root = NULL;
|
2015-09-23 16:44:17 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ext4_exit_sysfs(void)
|
|
|
|
{
|
2018-01-11 20:11:32 +00:00
|
|
|
kobject_put(ext4_feat);
|
2018-03-30 04:03:38 +00:00
|
|
|
ext4_feat = NULL;
|
2018-03-30 04:41:34 +00:00
|
|
|
kobject_put(ext4_root);
|
|
|
|
ext4_root = NULL;
|
2015-09-23 16:46:17 +00:00
|
|
|
remove_proc_entry(proc_dirname, NULL);
|
|
|
|
ext4_proc_root = NULL;
|
2015-09-23 16:44:17 +00:00
|
|
|
}
|
|
|
|
|