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
|
2010-04-06 22:14:15 +00:00
|
|
|
#include <linux/ceph/ceph_debug.h>
|
2009-10-06 18:31:14 +00:00
|
|
|
|
2009-12-15 22:44:32 +00:00
|
|
|
#include <linux/device.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2009-10-06 18:31:14 +00:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/ctype.h>
|
|
|
|
#include <linux/debugfs.h>
|
|
|
|
#include <linux/seq_file.h>
|
2020-03-20 03:45:01 +00:00
|
|
|
#include <linux/math64.h>
|
|
|
|
#include <linux/ktime.h>
|
2009-10-06 18:31:14 +00:00
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
#include <linux/ceph/libceph.h>
|
|
|
|
#include <linux/ceph/mon_client.h>
|
|
|
|
#include <linux/ceph/auth.h>
|
|
|
|
#include <linux/ceph/debugfs.h>
|
2009-10-06 18:31:14 +00:00
|
|
|
|
2010-09-28 16:53:10 +00:00
|
|
|
#include "super.h"
|
|
|
|
|
2009-11-12 23:05:52 +00:00
|
|
|
#ifdef CONFIG_DEBUG_FS
|
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
#include "mds_client.h"
|
2020-03-20 03:45:01 +00:00
|
|
|
#include "metric.h"
|
2009-10-06 18:31:14 +00:00
|
|
|
|
|
|
|
static int mdsmap_show(struct seq_file *s, void *p)
|
|
|
|
{
|
|
|
|
int i;
|
2010-04-06 22:14:15 +00:00
|
|
|
struct ceph_fs_client *fsc = s->private;
|
2017-03-28 09:04:13 +00:00
|
|
|
struct ceph_mdsmap *mdsmap;
|
2009-10-06 18:31:14 +00:00
|
|
|
|
2017-08-20 18:22:02 +00:00
|
|
|
if (!fsc->mdsc || !fsc->mdsc->mdsmap)
|
2009-10-06 18:31:14 +00:00
|
|
|
return 0;
|
2017-03-28 09:04:13 +00:00
|
|
|
mdsmap = fsc->mdsc->mdsmap;
|
|
|
|
seq_printf(s, "epoch %d\n", mdsmap->m_epoch);
|
|
|
|
seq_printf(s, "root %d\n", mdsmap->m_root);
|
|
|
|
seq_printf(s, "max_mds %d\n", mdsmap->m_max_mds);
|
|
|
|
seq_printf(s, "session_timeout %d\n", mdsmap->m_session_timeout);
|
|
|
|
seq_printf(s, "session_autoclose %d\n", mdsmap->m_session_autoclose);
|
2019-12-04 11:57:39 +00:00
|
|
|
for (i = 0; i < mdsmap->possible_max_rank; i++) {
|
2017-03-28 09:04:13 +00:00
|
|
|
struct ceph_entity_addr *addr = &mdsmap->m_info[i].addr;
|
|
|
|
int state = mdsmap->m_info[i].state;
|
2010-04-06 22:14:15 +00:00
|
|
|
seq_printf(s, "\tmds%d\t%s\t(%s)\n", i,
|
2019-05-06 13:38:47 +00:00
|
|
|
ceph_pr_addr(addr),
|
2009-10-06 18:31:14 +00:00
|
|
|
ceph_mds_state_name(state));
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
/*
|
|
|
|
* mdsc debugfs
|
|
|
|
*/
|
2009-10-06 18:31:14 +00:00
|
|
|
static int mdsc_show(struct seq_file *s, void *p)
|
|
|
|
{
|
2010-04-06 22:14:15 +00:00
|
|
|
struct ceph_fs_client *fsc = s->private;
|
|
|
|
struct ceph_mds_client *mdsc = fsc->mdsc;
|
2010-02-15 20:08:46 +00:00
|
|
|
struct ceph_mds_request *req;
|
|
|
|
struct rb_node *rp;
|
2019-05-09 10:11:25 +00:00
|
|
|
int pathlen = 0;
|
2009-10-06 18:31:14 +00:00
|
|
|
u64 pathbase;
|
|
|
|
char *path;
|
|
|
|
|
|
|
|
mutex_lock(&mdsc->mutex);
|
2010-02-15 20:08:46 +00:00
|
|
|
for (rp = rb_first(&mdsc->request_tree); rp; rp = rb_next(rp)) {
|
|
|
|
req = rb_entry(rp, struct ceph_mds_request, r_node);
|
2009-10-06 18:31:14 +00:00
|
|
|
|
2010-11-02 20:41:47 +00:00
|
|
|
if (req->r_request && req->r_session)
|
|
|
|
seq_printf(s, "%lld\tmds%d\t", req->r_tid,
|
|
|
|
req->r_session->s_mds);
|
|
|
|
else if (!req->r_request)
|
2009-10-06 18:31:14 +00:00
|
|
|
seq_printf(s, "%lld\t(no request)\t", req->r_tid);
|
2010-11-02 20:41:47 +00:00
|
|
|
else
|
|
|
|
seq_printf(s, "%lld\t(no session)\t", req->r_tid);
|
2009-10-06 18:31:14 +00:00
|
|
|
|
|
|
|
seq_printf(s, "%s", ceph_mds_op_name(req->r_op));
|
|
|
|
|
2017-02-01 18:49:09 +00:00
|
|
|
if (test_bit(CEPH_MDS_R_GOT_UNSAFE, &req->r_req_flags))
|
2014-06-06 21:35:38 +00:00
|
|
|
seq_puts(s, "\t(unsafe)");
|
2009-10-06 18:31:14 +00:00
|
|
|
else
|
2014-06-06 21:35:38 +00:00
|
|
|
seq_puts(s, "\t");
|
2009-10-06 18:31:14 +00:00
|
|
|
|
|
|
|
if (req->r_inode) {
|
|
|
|
seq_printf(s, " #%llx", ceph_ino(req->r_inode));
|
|
|
|
} else if (req->r_dentry) {
|
|
|
|
path = ceph_mdsc_build_path(req->r_dentry, &pathlen,
|
|
|
|
&pathbase, 0);
|
2010-08-26 09:07:24 +00:00
|
|
|
if (IS_ERR(path))
|
|
|
|
path = NULL;
|
2009-10-06 18:31:14 +00:00
|
|
|
spin_lock(&req->r_dentry->d_lock);
|
2014-10-22 00:11:25 +00:00
|
|
|
seq_printf(s, " #%llx/%pd (%s)",
|
2015-03-17 22:25:59 +00:00
|
|
|
ceph_ino(d_inode(req->r_dentry->d_parent)),
|
2014-10-22 00:11:25 +00:00
|
|
|
req->r_dentry,
|
2009-10-06 18:31:14 +00:00
|
|
|
path ? path : "");
|
|
|
|
spin_unlock(&req->r_dentry->d_lock);
|
2019-04-29 16:13:14 +00:00
|
|
|
ceph_mdsc_free_path(path, pathlen);
|
2009-10-06 18:31:14 +00:00
|
|
|
} else if (req->r_path1) {
|
|
|
|
seq_printf(s, " #%llx/%s", req->r_ino1.ino,
|
|
|
|
req->r_path1);
|
2014-03-01 14:22:57 +00:00
|
|
|
} else {
|
|
|
|
seq_printf(s, " #%llx", req->r_ino1.ino);
|
2009-10-06 18:31:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (req->r_old_dentry) {
|
|
|
|
path = ceph_mdsc_build_path(req->r_old_dentry, &pathlen,
|
|
|
|
&pathbase, 0);
|
2010-08-26 09:07:24 +00:00
|
|
|
if (IS_ERR(path))
|
|
|
|
path = NULL;
|
2009-10-06 18:31:14 +00:00
|
|
|
spin_lock(&req->r_old_dentry->d_lock);
|
2014-10-22 00:11:25 +00:00
|
|
|
seq_printf(s, " #%llx/%pd (%s)",
|
2013-02-05 21:40:09 +00:00
|
|
|
req->r_old_dentry_dir ?
|
|
|
|
ceph_ino(req->r_old_dentry_dir) : 0,
|
2014-10-22 00:11:25 +00:00
|
|
|
req->r_old_dentry,
|
2009-10-06 18:31:14 +00:00
|
|
|
path ? path : "");
|
|
|
|
spin_unlock(&req->r_old_dentry->d_lock);
|
2019-04-29 16:13:14 +00:00
|
|
|
ceph_mdsc_free_path(path, pathlen);
|
2016-04-18 08:51:37 +00:00
|
|
|
} else if (req->r_path2 && req->r_op != CEPH_MDS_OP_SYMLINK) {
|
2009-10-06 18:31:14 +00:00
|
|
|
if (req->r_ino2.ino)
|
|
|
|
seq_printf(s, " #%llx/%s", req->r_ino2.ino,
|
|
|
|
req->r_path2);
|
|
|
|
else
|
|
|
|
seq_printf(s, " %s", req->r_path2);
|
|
|
|
}
|
|
|
|
|
2014-06-06 21:35:38 +00:00
|
|
|
seq_puts(s, "\n");
|
2009-10-06 18:31:14 +00:00
|
|
|
}
|
|
|
|
mutex_unlock(&mdsc->mutex);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-05-13 01:40:53 +00:00
|
|
|
#define CEPH_LAT_METRIC_SHOW(name, total, avg, min, max, sq) { \
|
2020-03-20 03:45:01 +00:00
|
|
|
s64 _total, _avg, _min, _max, _sq, _st; \
|
|
|
|
_avg = ktime_to_us(avg); \
|
|
|
|
_min = ktime_to_us(min == KTIME_MAX ? 0 : min); \
|
|
|
|
_max = ktime_to_us(max); \
|
|
|
|
_total = total - 1; \
|
|
|
|
_sq = _total > 0 ? DIV64_U64_ROUND_CLOSEST(sq, _total) : 0; \
|
|
|
|
_st = int_sqrt64(_sq); \
|
|
|
|
_st = ktime_to_us(_st); \
|
|
|
|
seq_printf(s, "%-14s%-12lld%-16lld%-16lld%-16lld%lld\n", \
|
|
|
|
name, total, _avg, _min, _max, _st); \
|
|
|
|
}
|
|
|
|
|
2021-05-13 01:40:53 +00:00
|
|
|
#define CEPH_SZ_METRIC_SHOW(name, total, avg, min, max, sum) { \
|
|
|
|
u64 _min = min == U64_MAX ? 0 : min; \
|
|
|
|
seq_printf(s, "%-14s%-12lld%-16llu%-16llu%-16llu%llu\n", \
|
|
|
|
name, total, avg, _min, max, sum); \
|
|
|
|
}
|
|
|
|
|
2021-10-27 10:01:30 +00:00
|
|
|
static int metrics_file_show(struct seq_file *s, void *p)
|
2020-03-20 03:44:59 +00:00
|
|
|
{
|
|
|
|
struct ceph_fs_client *fsc = s->private;
|
2021-10-27 10:01:30 +00:00
|
|
|
struct ceph_client_metric *m = &fsc->mdsc->metric;
|
2020-03-20 03:45:01 +00:00
|
|
|
|
2020-09-03 13:01:40 +00:00
|
|
|
seq_printf(s, "item total\n");
|
|
|
|
seq_printf(s, "------------------------------------------\n");
|
2021-10-27 10:01:30 +00:00
|
|
|
seq_printf(s, "%-35s%lld\n", "total inodes",
|
|
|
|
percpu_counter_sum(&m->total_inodes));
|
|
|
|
seq_printf(s, "%-35s%lld\n", "opened files",
|
|
|
|
atomic64_read(&m->opened_files));
|
|
|
|
seq_printf(s, "%-35s%lld\n", "pinned i_caps",
|
|
|
|
atomic64_read(&m->total_caps));
|
|
|
|
seq_printf(s, "%-35s%lld\n", "opened inodes",
|
|
|
|
percpu_counter_sum(&m->opened_inodes));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int metrics_latency_show(struct seq_file *s, void *p)
|
|
|
|
{
|
|
|
|
struct ceph_fs_client *fsc = s->private;
|
|
|
|
struct ceph_client_metric *m = &fsc->mdsc->metric;
|
|
|
|
s64 total, sum, avg, min, max, sq;
|
|
|
|
|
2020-03-20 03:45:01 +00:00
|
|
|
seq_printf(s, "item total avg_lat(us) min_lat(us) max_lat(us) stdev(us)\n");
|
|
|
|
seq_printf(s, "-----------------------------------------------------------------------------------\n");
|
|
|
|
|
2021-03-22 12:28:49 +00:00
|
|
|
spin_lock(&m->read_metric_lock);
|
2020-03-20 03:45:01 +00:00
|
|
|
total = m->total_reads;
|
|
|
|
sum = m->read_latency_sum;
|
|
|
|
avg = total > 0 ? DIV64_U64_ROUND_CLOSEST(sum, total) : 0;
|
|
|
|
min = m->read_latency_min;
|
|
|
|
max = m->read_latency_max;
|
|
|
|
sq = m->read_latency_sq_sum;
|
2021-03-22 12:28:49 +00:00
|
|
|
spin_unlock(&m->read_metric_lock);
|
2021-05-13 01:40:53 +00:00
|
|
|
CEPH_LAT_METRIC_SHOW("read", total, avg, min, max, sq);
|
2020-03-20 03:45:01 +00:00
|
|
|
|
2021-03-22 12:28:49 +00:00
|
|
|
spin_lock(&m->write_metric_lock);
|
2020-03-20 03:45:01 +00:00
|
|
|
total = m->total_writes;
|
|
|
|
sum = m->write_latency_sum;
|
|
|
|
avg = total > 0 ? DIV64_U64_ROUND_CLOSEST(sum, total) : 0;
|
|
|
|
min = m->write_latency_min;
|
|
|
|
max = m->write_latency_max;
|
|
|
|
sq = m->write_latency_sq_sum;
|
2021-03-22 12:28:49 +00:00
|
|
|
spin_unlock(&m->write_metric_lock);
|
2021-05-13 01:40:53 +00:00
|
|
|
CEPH_LAT_METRIC_SHOW("write", total, avg, min, max, sq);
|
2020-03-20 03:45:01 +00:00
|
|
|
|
2021-03-22 12:28:49 +00:00
|
|
|
spin_lock(&m->metadata_metric_lock);
|
2020-03-20 03:45:02 +00:00
|
|
|
total = m->total_metadatas;
|
|
|
|
sum = m->metadata_latency_sum;
|
|
|
|
avg = total > 0 ? DIV64_U64_ROUND_CLOSEST(sum, total) : 0;
|
|
|
|
min = m->metadata_latency_min;
|
|
|
|
max = m->metadata_latency_max;
|
|
|
|
sq = m->metadata_latency_sq_sum;
|
2021-03-22 12:28:49 +00:00
|
|
|
spin_unlock(&m->metadata_metric_lock);
|
2021-05-13 01:40:53 +00:00
|
|
|
CEPH_LAT_METRIC_SHOW("metadata", total, avg, min, max, sq);
|
|
|
|
|
2021-10-27 10:01:30 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int metrics_size_show(struct seq_file *s, void *p)
|
|
|
|
{
|
|
|
|
struct ceph_fs_client *fsc = s->private;
|
|
|
|
struct ceph_client_metric *m = &fsc->mdsc->metric;
|
|
|
|
s64 total;
|
|
|
|
u64 sum_sz, avg_sz, min_sz, max_sz;
|
|
|
|
|
2021-05-13 01:40:53 +00:00
|
|
|
seq_printf(s, "item total avg_sz(bytes) min_sz(bytes) max_sz(bytes) total_sz(bytes)\n");
|
|
|
|
seq_printf(s, "----------------------------------------------------------------------------------------\n");
|
|
|
|
|
|
|
|
spin_lock(&m->read_metric_lock);
|
|
|
|
total = m->total_reads;
|
|
|
|
sum_sz = m->read_size_sum;
|
|
|
|
avg_sz = total > 0 ? DIV64_U64_ROUND_CLOSEST(sum_sz, total) : 0;
|
|
|
|
min_sz = m->read_size_min;
|
|
|
|
max_sz = m->read_size_max;
|
|
|
|
spin_unlock(&m->read_metric_lock);
|
|
|
|
CEPH_SZ_METRIC_SHOW("read", total, avg_sz, min_sz, max_sz, sum_sz);
|
|
|
|
|
|
|
|
spin_lock(&m->write_metric_lock);
|
|
|
|
total = m->total_writes;
|
|
|
|
sum_sz = m->write_size_sum;
|
|
|
|
avg_sz = total > 0 ? DIV64_U64_ROUND_CLOSEST(sum_sz, total) : 0;
|
|
|
|
min_sz = m->write_size_min;
|
|
|
|
max_sz = m->write_size_max;
|
|
|
|
spin_unlock(&m->write_metric_lock);
|
|
|
|
CEPH_SZ_METRIC_SHOW("write", total, avg_sz, min_sz, max_sz, sum_sz);
|
2020-03-20 03:45:02 +00:00
|
|
|
|
2021-10-27 10:01:30 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int metrics_caps_show(struct seq_file *s, void *p)
|
|
|
|
{
|
|
|
|
struct ceph_fs_client *fsc = s->private;
|
|
|
|
struct ceph_client_metric *m = &fsc->mdsc->metric;
|
|
|
|
int nr_caps = 0;
|
|
|
|
|
2020-03-20 03:44:59 +00:00
|
|
|
seq_printf(s, "item total miss hit\n");
|
|
|
|
seq_printf(s, "-------------------------------------------------\n");
|
|
|
|
|
|
|
|
seq_printf(s, "%-14s%-16lld%-16lld%lld\n", "d_lease",
|
|
|
|
atomic64_read(&m->total_dentries),
|
|
|
|
percpu_counter_sum(&m->d_lease_mis),
|
|
|
|
percpu_counter_sum(&m->d_lease_hit));
|
|
|
|
|
2020-06-30 07:52:16 +00:00
|
|
|
nr_caps = atomic64_read(&m->total_caps);
|
2020-03-20 03:45:00 +00:00
|
|
|
seq_printf(s, "%-14s%-16d%-16lld%lld\n", "caps", nr_caps,
|
|
|
|
percpu_counter_sum(&m->i_caps_mis),
|
|
|
|
percpu_counter_sum(&m->i_caps_hit));
|
|
|
|
|
2020-03-20 03:44:59 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-04-24 16:05:15 +00:00
|
|
|
static int caps_show_cb(struct inode *inode, struct ceph_cap *cap, void *p)
|
|
|
|
{
|
|
|
|
struct seq_file *s = p;
|
|
|
|
|
2020-08-24 03:00:58 +00:00
|
|
|
seq_printf(s, "0x%-17llx%-3d%-17s%-17s\n", ceph_ino(inode),
|
|
|
|
cap->session->s_mds,
|
2019-04-24 16:05:15 +00:00
|
|
|
ceph_cap_string(cap->issued),
|
|
|
|
ceph_cap_string(cap->implemented));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-10-06 18:31:14 +00:00
|
|
|
static int caps_show(struct seq_file *s, void *p)
|
|
|
|
{
|
2010-04-06 22:14:15 +00:00
|
|
|
struct ceph_fs_client *fsc = s->private;
|
2019-04-24 16:05:15 +00:00
|
|
|
struct ceph_mds_client *mdsc = fsc->mdsc;
|
|
|
|
int total, avail, used, reserved, min, i;
|
2019-11-20 17:00:59 +00:00
|
|
|
struct cap_wait *cw;
|
2009-10-06 18:31:14 +00:00
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
ceph_reservation_status(fsc, &total, &avail, &used, &reserved, &min);
|
2009-10-06 18:31:14 +00:00
|
|
|
seq_printf(s, "total\t\t%d\n"
|
2010-02-17 18:02:43 +00:00
|
|
|
"avail\t\t%d\n"
|
|
|
|
"used\t\t%d\n"
|
|
|
|
"reserved\t%d\n"
|
2019-04-24 16:05:15 +00:00
|
|
|
"min\t\t%d\n\n",
|
2010-02-17 18:02:43 +00:00
|
|
|
total, avail, used, reserved, min);
|
2020-08-24 03:00:58 +00:00
|
|
|
seq_printf(s, "ino mds issued implemented\n");
|
|
|
|
seq_printf(s, "--------------------------------------------------\n");
|
2019-04-24 16:05:15 +00:00
|
|
|
|
|
|
|
mutex_lock(&mdsc->mutex);
|
|
|
|
for (i = 0; i < mdsc->max_sessions; i++) {
|
|
|
|
struct ceph_mds_session *session;
|
|
|
|
|
|
|
|
session = __ceph_lookup_mds_session(mdsc, i);
|
|
|
|
if (!session)
|
|
|
|
continue;
|
|
|
|
mutex_unlock(&mdsc->mutex);
|
|
|
|
mutex_lock(&session->s_mutex);
|
|
|
|
ceph_iterate_session_caps(session, caps_show_cb, s);
|
|
|
|
mutex_unlock(&session->s_mutex);
|
|
|
|
ceph_put_mds_session(session);
|
|
|
|
mutex_lock(&mdsc->mutex);
|
|
|
|
}
|
|
|
|
mutex_unlock(&mdsc->mutex);
|
|
|
|
|
2019-11-20 17:00:59 +00:00
|
|
|
seq_printf(s, "\n\nWaiters:\n--------\n");
|
|
|
|
seq_printf(s, "tgid ino need want\n");
|
|
|
|
seq_printf(s, "-----------------------------------------------------\n");
|
|
|
|
|
|
|
|
spin_lock(&mdsc->caps_list_lock);
|
|
|
|
list_for_each_entry(cw, &mdsc->cap_wait_list, list) {
|
ceph: fix inode number handling on arches with 32-bit ino_t
Tuan and Ulrich mentioned that they were hitting a problem on s390x,
which has a 32-bit ino_t value, even though it's a 64-bit arch (for
historical reasons).
I think the current handling of inode numbers in the ceph driver is
wrong. It tries to use 32-bit inode numbers on 32-bit arches, but that's
actually not a problem. 32-bit arches can deal with 64-bit inode numbers
just fine when userland code is compiled with LFS support (the common
case these days).
What we really want to do is just use 64-bit numbers everywhere, unless
someone has mounted with the ino32 mount option. In that case, we want
to ensure that we hash the inode number down to something that will fit
in 32 bits before presenting the value to userland.
Add new helper functions that do this, and only do the conversion before
presenting these values to userland in getattr and readdir.
The inode table hashvalue is changed to just cast the inode number to
unsigned long, as low-order bits are the most likely to vary anyway.
While it's not strictly required, we do want to put something in
inode->i_ino. Instead of basing it on BITS_PER_LONG, however, base it on
the size of the ino_t type.
NOTE: This is a user-visible change on 32-bit arches:
1/ inode numbers will be seen to have changed between kernel versions.
32-bit arches will see large inode numbers now instead of the hashed
ones they saw before.
2/ any really old software not built with LFS support may start failing
stat() calls with -EOVERFLOW on inode numbers >2^32. Nothing much we
can do about these, but hopefully the intersection of people running
such code on ceph will be very small.
The workaround for both problems is to mount with "-o ino32".
[ idryomov: changelog tweak ]
URL: https://tracker.ceph.com/issues/46828
Reported-by: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
Reported-and-Tested-by: Tuan Hoang1 <Tuan.Hoang1@ibm.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: "Yan, Zheng" <zyan@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
2020-08-18 12:03:48 +00:00
|
|
|
seq_printf(s, "%-13d0x%-17llx%-17s%-17s\n", cw->tgid, cw->ino,
|
2019-11-20 17:00:59 +00:00
|
|
|
ceph_cap_string(cw->need),
|
|
|
|
ceph_cap_string(cw->want));
|
|
|
|
}
|
|
|
|
spin_unlock(&mdsc->caps_list_lock);
|
|
|
|
|
2009-10-06 18:31:14 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-09-12 15:58:49 +00:00
|
|
|
static int mds_sessions_show(struct seq_file *s, void *ptr)
|
|
|
|
{
|
|
|
|
struct ceph_fs_client *fsc = s->private;
|
|
|
|
struct ceph_mds_client *mdsc = fsc->mdsc;
|
|
|
|
struct ceph_auth_client *ac = fsc->client->monc.auth;
|
|
|
|
struct ceph_options *opt = fsc->client->options;
|
2020-07-23 15:22:40 +00:00
|
|
|
int mds;
|
2014-09-12 15:58:49 +00:00
|
|
|
|
|
|
|
mutex_lock(&mdsc->mutex);
|
|
|
|
|
|
|
|
/* The 'num' portion of an 'entity name' */
|
|
|
|
seq_printf(s, "global_id %llu\n", ac->global_id);
|
|
|
|
|
|
|
|
/* The -o name mount argument */
|
|
|
|
seq_printf(s, "name \"%s\"\n", opt->name ? opt->name : "");
|
|
|
|
|
|
|
|
/* The list of MDS session rank+state */
|
|
|
|
for (mds = 0; mds < mdsc->max_sessions; mds++) {
|
|
|
|
struct ceph_mds_session *session =
|
|
|
|
__ceph_lookup_mds_session(mdsc, mds);
|
|
|
|
if (!session) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
mutex_unlock(&mdsc->mutex);
|
|
|
|
seq_printf(s, "mds.%d %s\n",
|
|
|
|
session->s_mds,
|
|
|
|
ceph_session_state_name(session->s_state));
|
|
|
|
|
|
|
|
ceph_put_mds_session(session);
|
|
|
|
mutex_lock(&mdsc->mutex);
|
|
|
|
}
|
|
|
|
mutex_unlock(&mdsc->mutex);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-11-11 01:29:39 +00:00
|
|
|
static int status_show(struct seq_file *s, void *p)
|
|
|
|
{
|
|
|
|
struct ceph_fs_client *fsc = s->private;
|
|
|
|
struct ceph_entity_inst *inst = &fsc->client->msgr.inst;
|
|
|
|
struct ceph_entity_addr *client_addr = ceph_client_addr(fsc->client);
|
|
|
|
|
|
|
|
seq_printf(s, "instance: %s.%lld %s/%u\n", ENTITY_NAME(inst->name),
|
|
|
|
ceph_pr_addr(client_addr), le32_to_cpu(client_addr->nonce));
|
|
|
|
seq_printf(s, "blocklisted: %s\n", fsc->blocklisted ? "true" : "false");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-01-28 19:12:22 +00:00
|
|
|
DEFINE_SHOW_ATTRIBUTE(mdsmap);
|
|
|
|
DEFINE_SHOW_ATTRIBUTE(mdsc);
|
|
|
|
DEFINE_SHOW_ATTRIBUTE(caps);
|
|
|
|
DEFINE_SHOW_ATTRIBUTE(mds_sessions);
|
2020-11-11 01:29:39 +00:00
|
|
|
DEFINE_SHOW_ATTRIBUTE(status);
|
2021-10-27 10:01:30 +00:00
|
|
|
DEFINE_SHOW_ATTRIBUTE(metrics_file);
|
|
|
|
DEFINE_SHOW_ATTRIBUTE(metrics_latency);
|
|
|
|
DEFINE_SHOW_ATTRIBUTE(metrics_size);
|
|
|
|
DEFINE_SHOW_ATTRIBUTE(metrics_caps);
|
2010-04-06 22:14:15 +00:00
|
|
|
|
2009-10-06 18:31:14 +00:00
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
/*
|
|
|
|
* debugfs
|
|
|
|
*/
|
2009-12-18 21:51:57 +00:00
|
|
|
static int congestion_kb_set(void *data, u64 val)
|
|
|
|
{
|
2010-04-06 22:14:15 +00:00
|
|
|
struct ceph_fs_client *fsc = (struct ceph_fs_client *)data;
|
2009-12-18 21:51:57 +00:00
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
fsc->mount_options->congestion_kb = (int)val;
|
2009-12-18 21:51:57 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int congestion_kb_get(void *data, u64 *val)
|
|
|
|
{
|
2010-04-06 22:14:15 +00:00
|
|
|
struct ceph_fs_client *fsc = (struct ceph_fs_client *)data;
|
2009-12-18 21:51:57 +00:00
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
*val = (u64)fsc->mount_options->congestion_kb;
|
2009-12-18 21:51:57 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_SIMPLE_ATTRIBUTE(congestion_kb_fops, congestion_kb_get,
|
|
|
|
congestion_kb_set, "%llu\n");
|
|
|
|
|
2009-10-06 18:31:14 +00:00
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
void ceph_fs_debugfs_cleanup(struct ceph_fs_client *fsc)
|
2009-10-06 18:31:14 +00:00
|
|
|
{
|
2010-04-06 22:14:15 +00:00
|
|
|
dout("ceph_fs_debugfs_cleanup\n");
|
|
|
|
debugfs_remove(fsc->debugfs_bdi);
|
|
|
|
debugfs_remove(fsc->debugfs_congestion_kb);
|
|
|
|
debugfs_remove(fsc->debugfs_mdsmap);
|
2014-09-12 15:58:49 +00:00
|
|
|
debugfs_remove(fsc->debugfs_mds_sessions);
|
2010-04-06 22:14:15 +00:00
|
|
|
debugfs_remove(fsc->debugfs_caps);
|
2021-10-27 10:01:30 +00:00
|
|
|
debugfs_remove(fsc->debugfs_status);
|
2010-04-06 22:14:15 +00:00
|
|
|
debugfs_remove(fsc->debugfs_mdsc);
|
2021-10-27 10:01:30 +00:00
|
|
|
debugfs_remove_recursive(fsc->debugfs_metrics_dir);
|
2009-10-06 18:31:14 +00:00
|
|
|
}
|
|
|
|
|
2019-06-12 14:55:38 +00:00
|
|
|
void ceph_fs_debugfs_init(struct ceph_fs_client *fsc)
|
2009-10-06 18:31:14 +00:00
|
|
|
{
|
2010-04-06 22:14:15 +00:00
|
|
|
char name[100];
|
2009-10-06 18:31:14 +00:00
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
dout("ceph_fs_debugfs_init\n");
|
|
|
|
fsc->debugfs_congestion_kb =
|
|
|
|
debugfs_create_file("writeback_congestion_kb",
|
|
|
|
0600,
|
|
|
|
fsc->client->debugfs_dir,
|
|
|
|
fsc,
|
|
|
|
&congestion_kb_fops);
|
2009-10-06 18:31:14 +00:00
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
snprintf(name, sizeof(name), "../../bdi/%s",
|
2020-05-04 12:47:55 +00:00
|
|
|
bdi_dev_name(fsc->sb->s_bdi));
|
2010-04-06 22:14:15 +00:00
|
|
|
fsc->debugfs_bdi =
|
|
|
|
debugfs_create_symlink("bdi",
|
|
|
|
fsc->client->debugfs_dir,
|
|
|
|
name);
|
2009-10-06 18:31:14 +00:00
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
fsc->debugfs_mdsmap = debugfs_create_file("mdsmap",
|
2018-02-10 06:18:06 +00:00
|
|
|
0400,
|
2010-04-06 22:14:15 +00:00
|
|
|
fsc->client->debugfs_dir,
|
|
|
|
fsc,
|
2020-01-28 19:12:22 +00:00
|
|
|
&mdsmap_fops);
|
2009-10-06 18:31:14 +00:00
|
|
|
|
2014-09-12 15:58:49 +00:00
|
|
|
fsc->debugfs_mds_sessions = debugfs_create_file("mds_sessions",
|
2018-02-10 06:18:06 +00:00
|
|
|
0400,
|
2014-09-12 15:58:49 +00:00
|
|
|
fsc->client->debugfs_dir,
|
|
|
|
fsc,
|
2020-01-28 19:12:22 +00:00
|
|
|
&mds_sessions_fops);
|
2014-09-12 15:58:49 +00:00
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
fsc->debugfs_mdsc = debugfs_create_file("mdsc",
|
2018-02-10 06:18:06 +00:00
|
|
|
0400,
|
2010-04-06 22:14:15 +00:00
|
|
|
fsc->client->debugfs_dir,
|
|
|
|
fsc,
|
2020-01-28 19:12:22 +00:00
|
|
|
&mdsc_fops);
|
2009-10-06 18:31:14 +00:00
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
fsc->debugfs_caps = debugfs_create_file("caps",
|
2020-03-20 03:44:59 +00:00
|
|
|
0400,
|
|
|
|
fsc->client->debugfs_dir,
|
|
|
|
fsc,
|
|
|
|
&caps_fops);
|
2020-11-11 01:29:39 +00:00
|
|
|
|
|
|
|
fsc->debugfs_status = debugfs_create_file("status",
|
|
|
|
0400,
|
|
|
|
fsc->client->debugfs_dir,
|
|
|
|
fsc,
|
|
|
|
&status_fops);
|
2021-10-27 10:01:30 +00:00
|
|
|
|
|
|
|
fsc->debugfs_metrics_dir = debugfs_create_dir("metrics",
|
|
|
|
fsc->client->debugfs_dir);
|
|
|
|
|
|
|
|
debugfs_create_file("file", 0400, fsc->debugfs_metrics_dir, fsc,
|
|
|
|
&metrics_file_fops);
|
|
|
|
debugfs_create_file("latency", 0400, fsc->debugfs_metrics_dir, fsc,
|
|
|
|
&metrics_latency_fops);
|
|
|
|
debugfs_create_file("size", 0400, fsc->debugfs_metrics_dir, fsc,
|
|
|
|
&metrics_size_fops);
|
|
|
|
debugfs_create_file("caps", 0400, fsc->debugfs_metrics_dir, fsc,
|
|
|
|
&metrics_caps_fops);
|
2009-10-06 18:31:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-03 17:25:11 +00:00
|
|
|
#else /* CONFIG_DEBUG_FS */
|
2009-11-12 23:05:52 +00:00
|
|
|
|
2019-06-12 14:55:38 +00:00
|
|
|
void ceph_fs_debugfs_init(struct ceph_fs_client *fsc)
|
2009-11-12 23:05:52 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
void ceph_fs_debugfs_cleanup(struct ceph_fs_client *fsc)
|
2009-11-12 23:05:52 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-08-03 17:25:11 +00:00
|
|
|
#endif /* CONFIG_DEBUG_FS */
|