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 */
|
2009-10-06 18:31:07 +00:00
|
|
|
#ifndef _FS_CEPH_SUPER_H
|
|
|
|
#define _FS_CEPH_SUPER_H
|
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
#include <linux/ceph/ceph_debug.h>
|
2023-11-07 02:44:41 +00:00
|
|
|
#include <linux/ceph/osd_client.h>
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2024-10-01 19:35:57 +00:00
|
|
|
#include <linux/unaligned.h>
|
2009-10-06 18:31:07 +00:00
|
|
|
#include <linux/backing-dev.h>
|
|
|
|
#include <linux/completion.h>
|
|
|
|
#include <linux/exportfs.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/mempool.h>
|
|
|
|
#include <linux/pagemap.h>
|
|
|
|
#include <linux/wait.h>
|
2010-01-18 00:53:08 +00:00
|
|
|
#include <linux/writeback.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>
|
2014-02-16 16:35:52 +00:00
|
|
|
#include <linux/posix_acl.h>
|
2017-03-03 09:15:07 +00:00
|
|
|
#include <linux/refcount.h>
|
2019-08-06 13:07:51 +00:00
|
|
|
#include <linux/security.h>
|
2021-06-29 21:37:05 +00:00
|
|
|
#include <linux/netfs.h>
|
|
|
|
#include <linux/fscache.h>
|
2022-05-10 01:47:01 +00:00
|
|
|
#include <linux/hashtable.h>
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
#include <linux/ceph/libceph.h>
|
2020-09-08 13:47:40 +00:00
|
|
|
#include "crypto.h"
|
2009-10-06 18:31:07 +00:00
|
|
|
|
|
|
|
/* large granularity for statfs utilization stats to facilitate
|
|
|
|
* large volume sizes on 32-bit machines. */
|
2013-02-22 23:31:00 +00:00
|
|
|
#define CEPH_BLOCK_SHIFT 22 /* 4 MB */
|
2009-10-06 18:31:07 +00:00
|
|
|
#define CEPH_BLOCK (1 << CEPH_BLOCK_SHIFT)
|
2021-11-10 18:00:21 +00:00
|
|
|
#define CEPH_4K_BLOCK_SHIFT 12 /* 4 KB */
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2020-09-14 11:39:19 +00:00
|
|
|
#define CEPH_MOUNT_OPT_CLEANRECOVER (1<<1) /* auto reonnect (clean mode) after blocklisted */
|
2010-04-06 22:14:15 +00:00
|
|
|
#define CEPH_MOUNT_OPT_DIRSTAT (1<<4) /* `cat dirname` for stats */
|
|
|
|
#define CEPH_MOUNT_OPT_RBYTES (1<<5) /* dir st_bytes = rbytes */
|
|
|
|
#define CEPH_MOUNT_OPT_NOASYNCREADDIR (1<<7) /* no dcache readdir */
|
2011-01-22 00:44:03 +00:00
|
|
|
#define CEPH_MOUNT_OPT_INO32 (1<<8) /* 32 bit inos */
|
2012-01-10 17:12:55 +00:00
|
|
|
#define CEPH_MOUNT_OPT_DCACHE (1<<9) /* use dcache for readdir etc */
|
2013-08-21 21:29:54 +00:00
|
|
|
#define CEPH_MOUNT_OPT_FSCACHE (1<<10) /* use fscache */
|
2015-04-27 07:33:28 +00:00
|
|
|
#define CEPH_MOUNT_OPT_NOPOOLPERM (1<<11) /* no pool permission check */
|
2016-11-10 08:02:06 +00:00
|
|
|
#define CEPH_MOUNT_OPT_MOUNTWAIT (1<<12) /* mount waits if no mds is up */
|
2018-01-31 10:53:13 +00:00
|
|
|
#define CEPH_MOUNT_OPT_NOQUOTADF (1<<13) /* no root dir quota in statfs */
|
2018-10-15 15:46:00 +00:00
|
|
|
#define CEPH_MOUNT_OPT_NOCOPYFROM (1<<14) /* don't use RADOS 'copy-from' op */
|
ceph: perform asynchronous unlink if we have sufficient caps
The MDS is getting a new lock-caching facility that will allow it
to cache the necessary locks to allow asynchronous directory operations.
Since the CEPH_CAP_FILE_* caps are currently unused on directories,
we can repurpose those bits for this purpose.
When performing an unlink, if we have Fx on the parent directory,
and CEPH_CAP_DIR_UNLINK (aka Fr), and we know that the dentry being
removed is the primary link, then then we can fire off an unlink
request immediately and don't need to wait on reply before returning.
In that situation, just fix up the dcache and link count and return
immediately after issuing the call to the MDS. This does mean that we
need to hold an extra reference to the inode being unlinked, and extra
references to the caps to avoid races. Those references are put and
error handling is done in the r_callback routine.
If the operation ends up failing, then set a writeback error on the
directory inode, and the inode itself that can be fetched later by
an fsync on the dir.
The behavior of dir caps is slightly different from caps on normal
files. Because these are just considered an optimization, if the
session is reconnected, we will not automatically reclaim them. They
are instead considered lost until we do another synchronous op in the
parent directory.
Async dirops are enabled via the "nowsync" mount option, which is
patterned after the xfs "wsync" mount option. For now, the default
is "wsync", but eventually we may flip that.
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: "Yan, Zheng" <zyan@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
2019-04-02 19:35:56 +00:00
|
|
|
#define CEPH_MOUNT_OPT_ASYNC_DIROPS (1<<15) /* allow async directory ops */
|
2021-11-30 19:12:13 +00:00
|
|
|
#define CEPH_MOUNT_OPT_NOPAGECACHE (1<<16) /* bypass pagecache altogether */
|
2022-02-26 11:33:03 +00:00
|
|
|
#define CEPH_MOUNT_OPT_SPARSEREAD (1<<17) /* always do sparse reads */
|
2010-07-07 16:06:08 +00:00
|
|
|
|
2018-12-10 10:23:12 +00:00
|
|
|
#define CEPH_MOUNT_OPT_DEFAULT \
|
|
|
|
(CEPH_MOUNT_OPT_DCACHE | \
|
2021-08-09 15:55:15 +00:00
|
|
|
CEPH_MOUNT_OPT_NOCOPYFROM | \
|
|
|
|
CEPH_MOUNT_OPT_ASYNC_DIROPS)
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
#define ceph_set_mount_opt(fsc, opt) \
|
ceph: perform asynchronous unlink if we have sufficient caps
The MDS is getting a new lock-caching facility that will allow it
to cache the necessary locks to allow asynchronous directory operations.
Since the CEPH_CAP_FILE_* caps are currently unused on directories,
we can repurpose those bits for this purpose.
When performing an unlink, if we have Fx on the parent directory,
and CEPH_CAP_DIR_UNLINK (aka Fr), and we know that the dentry being
removed is the primary link, then then we can fire off an unlink
request immediately and don't need to wait on reply before returning.
In that situation, just fix up the dcache and link count and return
immediately after issuing the call to the MDS. This does mean that we
need to hold an extra reference to the inode being unlinked, and extra
references to the caps to avoid races. Those references are put and
error handling is done in the r_callback routine.
If the operation ends up failing, then set a writeback error on the
directory inode, and the inode itself that can be fetched later by
an fsync on the dir.
The behavior of dir caps is slightly different from caps on normal
files. Because these are just considered an optimization, if the
session is reconnected, we will not automatically reclaim them. They
are instead considered lost until we do another synchronous op in the
parent directory.
Async dirops are enabled via the "nowsync" mount option, which is
patterned after the xfs "wsync" mount option. For now, the default
is "wsync", but eventually we may flip that.
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: "Yan, Zheng" <zyan@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
2019-04-02 19:35:56 +00:00
|
|
|
(fsc)->mount_options->flags |= CEPH_MOUNT_OPT_##opt
|
|
|
|
#define ceph_clear_mount_opt(fsc, opt) \
|
|
|
|
(fsc)->mount_options->flags &= ~CEPH_MOUNT_OPT_##opt
|
2010-04-06 22:14:15 +00:00
|
|
|
#define ceph_test_mount_opt(fsc, opt) \
|
|
|
|
(!!((fsc)->mount_options->flags & CEPH_MOUNT_OPT_##opt))
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2017-07-11 07:56:09 +00:00
|
|
|
/* max size of osd read request, limited by libceph */
|
|
|
|
#define CEPH_MAX_READ_SIZE CEPH_MSG_MAX_DATA_LEN
|
2024-11-15 13:11:56 +00:00
|
|
|
/* osd has a configurable limitation of max write size.
|
2017-07-11 09:34:46 +00:00
|
|
|
* CEPH_MSG_MAX_DATA_LEN should be small enough. */
|
|
|
|
#define CEPH_MAX_WRITE_SIZE CEPH_MSG_MAX_DATA_LEN
|
2017-01-10 13:17:56 +00:00
|
|
|
#define CEPH_RASIZE_DEFAULT (8192*1024) /* max readahead */
|
2010-04-06 22:14:15 +00:00
|
|
|
#define CEPH_MAX_READDIR_DEFAULT 1024
|
|
|
|
#define CEPH_MAX_READDIR_BYTES_DEFAULT (512*1024)
|
|
|
|
#define CEPH_SNAPDIRNAME_DEFAULT ".snap"
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2017-07-11 10:49:44 +00:00
|
|
|
/*
|
|
|
|
* Delay telling the MDS we no longer want caps, in case we reopen
|
|
|
|
* the file. Delay a minimum amount of time, even if we send a cap
|
|
|
|
* message for some other reason. Otherwise, take the oppotunity to
|
|
|
|
* update the mds to avoid sending another message later.
|
|
|
|
*/
|
|
|
|
#define CEPH_CAPS_WANTED_DELAY_MIN_DEFAULT 5 /* cap release delay */
|
|
|
|
#define CEPH_CAPS_WANTED_DELAY_MAX_DEFAULT 60 /* cap release delay */
|
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
struct ceph_mount_options {
|
2019-09-09 19:58:55 +00:00
|
|
|
unsigned int flags;
|
2010-04-06 22:14:15 +00:00
|
|
|
|
2019-09-09 19:58:55 +00:00
|
|
|
unsigned int wsize; /* max write size */
|
|
|
|
unsigned int rsize; /* max read size */
|
|
|
|
unsigned int rasize; /* max readahead */
|
|
|
|
unsigned int congestion_kb; /* max writeback in flight */
|
|
|
|
unsigned int caps_wanted_delay_min, caps_wanted_delay_max;
|
2019-02-01 06:57:15 +00:00
|
|
|
int caps_max;
|
2019-09-09 19:58:55 +00:00
|
|
|
unsigned int max_readdir; /* max readdir result (entries) */
|
|
|
|
unsigned int max_readdir_bytes; /* max readdir result (bytes) */
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2021-07-14 10:05:52 +00:00
|
|
|
bool new_dev_syntax;
|
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
/*
|
|
|
|
* everything above this point can be memcmp'd; everything below
|
|
|
|
* is handled in compare_mount_options()
|
|
|
|
*/
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
char *snapdir_name; /* default ".snap" */
|
2016-07-08 03:25:38 +00:00
|
|
|
char *mds_namespace; /* default NULL */
|
2020-02-10 21:51:08 +00:00
|
|
|
char *server_path; /* default NULL (means "/") */
|
2017-06-27 03:57:56 +00:00
|
|
|
char *fscache_uniq; /* default NULL */
|
2021-07-14 10:05:52 +00:00
|
|
|
char *mon_addr;
|
2020-09-08 13:47:40 +00:00
|
|
|
struct fscrypt_dummy_policy dummy_enc_policy;
|
2010-04-06 22:14:15 +00:00
|
|
|
};
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2023-02-01 01:36:44 +00:00
|
|
|
/* mount state */
|
|
|
|
enum {
|
|
|
|
CEPH_MOUNT_MOUNTING,
|
|
|
|
CEPH_MOUNT_MOUNTED,
|
|
|
|
CEPH_MOUNT_UNMOUNTING,
|
|
|
|
CEPH_MOUNT_UNMOUNTED,
|
|
|
|
CEPH_MOUNT_SHUTDOWN,
|
|
|
|
CEPH_MOUNT_RECOVER,
|
2023-02-01 01:36:45 +00:00
|
|
|
CEPH_MOUNT_FENCE_IO,
|
2023-02-01 01:36:44 +00:00
|
|
|
};
|
|
|
|
|
2022-05-10 01:47:01 +00:00
|
|
|
#define CEPH_ASYNC_CREATE_CONFLICT_BITS 8
|
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
struct ceph_fs_client {
|
2009-10-06 18:31:07 +00:00
|
|
|
struct super_block *sb;
|
|
|
|
|
2020-07-16 14:05:57 +00:00
|
|
|
struct list_head metric_wakeup;
|
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
struct ceph_mount_options *mount_options;
|
|
|
|
struct ceph_client *client;
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2020-10-06 12:38:20 +00:00
|
|
|
int mount_state;
|
2019-07-25 12:16:46 +00:00
|
|
|
|
2020-09-14 11:39:19 +00:00
|
|
|
bool blocklisted;
|
2019-07-25 12:16:47 +00:00
|
|
|
|
2020-01-08 10:03:53 +00:00
|
|
|
bool have_copy_from2;
|
|
|
|
|
2019-07-25 12:16:46 +00:00
|
|
|
u32 filp_gen;
|
2018-07-19 14:15:24 +00:00
|
|
|
loff_t max_file_size;
|
2010-02-17 18:02:43 +00:00
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
struct ceph_mds_client *mdsc;
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2019-01-14 09:21:19 +00:00
|
|
|
atomic_long_t writeback_count;
|
2022-03-22 21:39:04 +00:00
|
|
|
bool write_congested;
|
2019-01-14 09:21:19 +00:00
|
|
|
|
2019-05-18 03:18:44 +00:00
|
|
|
struct workqueue_struct *inode_wq;
|
2019-01-14 09:21:19 +00:00
|
|
|
struct workqueue_struct *cap_wq;
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2022-05-10 01:47:01 +00:00
|
|
|
DECLARE_HASHTABLE(async_unlink_conflict, CEPH_ASYNC_CREATE_CONFLICT_BITS);
|
|
|
|
spinlock_t async_unlink_conflict_lock;
|
|
|
|
|
2009-11-19 00:50:41 +00:00
|
|
|
#ifdef CONFIG_DEBUG_FS
|
2010-04-06 22:14:15 +00:00
|
|
|
struct dentry *debugfs_dentry_lru, *debugfs_caps;
|
2009-12-18 21:51:57 +00:00
|
|
|
struct dentry *debugfs_congestion_kb;
|
2009-12-15 22:44:32 +00:00
|
|
|
struct dentry *debugfs_bdi;
|
2010-04-06 22:14:15 +00:00
|
|
|
struct dentry *debugfs_mdsc, *debugfs_mdsmap;
|
2020-11-11 01:29:39 +00:00
|
|
|
struct dentry *debugfs_status;
|
2014-09-12 15:58:49 +00:00
|
|
|
struct dentry *debugfs_mds_sessions;
|
2021-10-27 10:01:30 +00:00
|
|
|
struct dentry *debugfs_metrics_dir;
|
2009-11-19 00:50:41 +00:00
|
|
|
#endif
|
2013-08-21 21:29:54 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_CEPH_FSCACHE
|
2021-12-07 13:44:50 +00:00
|
|
|
struct fscache_volume *fscache;
|
2013-08-21 21:29:54 +00:00
|
|
|
#endif
|
2020-09-08 13:47:40 +00:00
|
|
|
#ifdef CONFIG_FS_ENCRYPTION
|
|
|
|
struct fscrypt_dummy_policy fsc_dummy_enc_policy;
|
|
|
|
#endif
|
2009-10-06 18:31:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* File i/o capability. This tracks shared state with the metadata
|
|
|
|
* server that allows us to cache or writeback attributes or to read
|
|
|
|
* and write data. For any given inode, we should have one or more
|
|
|
|
* capabilities, one issued by each metadata server, and our
|
|
|
|
* cumulative access is the OR of all issued capabilities.
|
|
|
|
*
|
|
|
|
* Each cap is referenced by the inode's i_caps rbtree and by per-mds
|
|
|
|
* session capability lists.
|
|
|
|
*/
|
|
|
|
struct ceph_cap {
|
|
|
|
struct ceph_inode_info *ci;
|
|
|
|
struct rb_node ci_node; /* per-ci cap tree */
|
|
|
|
struct ceph_mds_session *session;
|
|
|
|
struct list_head session_caps; /* per-session caplist */
|
|
|
|
u64 cap_id; /* unique cap id (mds provided) */
|
2015-05-14 09:22:42 +00:00
|
|
|
union {
|
|
|
|
/* in-use caps */
|
|
|
|
struct {
|
|
|
|
int issued; /* latest, from the mds */
|
|
|
|
int implemented; /* implemented superset of
|
|
|
|
issued (for revocation) */
|
2020-10-06 16:24:19 +00:00
|
|
|
int mds; /* mds index for this cap */
|
|
|
|
int mds_wanted; /* caps wanted from this mds */
|
2015-05-14 09:22:42 +00:00
|
|
|
};
|
|
|
|
/* caps to release */
|
|
|
|
struct {
|
|
|
|
u64 cap_ino;
|
|
|
|
int queue_release;
|
|
|
|
};
|
|
|
|
};
|
2009-11-09 20:05:48 +00:00
|
|
|
u32 seq, issue_seq, mseq;
|
|
|
|
u32 cap_gen; /* active/stale cycle */
|
2009-10-06 18:31:07 +00:00
|
|
|
unsigned long last_used;
|
|
|
|
struct list_head caps_item;
|
|
|
|
};
|
|
|
|
|
2024-07-12 04:40:19 +00:00
|
|
|
#define CHECK_CAPS_AUTHONLY 1 /* only check auth cap */
|
|
|
|
#define CHECK_CAPS_FLUSH 2 /* flush any dirty caps */
|
|
|
|
#define CHECK_CAPS_NOINVAL 4 /* don't invalidate pagecache */
|
|
|
|
#define CHECK_CAPS_FLUSH_FORCE 8 /* force flush any caps */
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2016-07-04 10:06:41 +00:00
|
|
|
struct ceph_cap_flush {
|
|
|
|
u64 tid;
|
2021-08-18 13:38:42 +00:00
|
|
|
int caps;
|
2016-07-07 07:22:38 +00:00
|
|
|
bool wake; /* wake up flush waiters when finish ? */
|
2021-08-18 13:38:42 +00:00
|
|
|
bool is_capsnap; /* true means capsnap */
|
2016-07-04 10:06:41 +00:00
|
|
|
struct list_head g_list; // global
|
|
|
|
struct list_head i_list; // per inode
|
|
|
|
};
|
|
|
|
|
2009-10-06 18:31:07 +00:00
|
|
|
/*
|
|
|
|
* Snapped cap state that is pending flush to mds. When a snapshot occurs,
|
|
|
|
* we first complete any in-process sync writes and writeback any dirty
|
|
|
|
* data before flushing the snapped state (tracked here) back to the MDS.
|
|
|
|
*/
|
|
|
|
struct ceph_cap_snap {
|
2017-03-03 09:15:07 +00:00
|
|
|
refcount_t nref;
|
2016-07-04 10:06:41 +00:00
|
|
|
struct list_head ci_item;
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2016-07-04 10:06:41 +00:00
|
|
|
struct ceph_cap_flush cap_flush;
|
|
|
|
|
|
|
|
u64 follows;
|
2009-10-06 18:31:07 +00:00
|
|
|
int issued, dirty;
|
|
|
|
struct ceph_snap_context *context;
|
|
|
|
|
2011-07-26 08:52:22 +00:00
|
|
|
umode_t mode;
|
2013-01-31 10:56:19 +00:00
|
|
|
kuid_t uid;
|
|
|
|
kgid_t gid;
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2010-08-22 22:03:56 +00:00
|
|
|
struct ceph_buffer *xattr_blob;
|
2009-10-06 18:31:07 +00:00
|
|
|
u64 xattr_version;
|
|
|
|
|
|
|
|
u64 size;
|
2019-06-06 12:06:40 +00:00
|
|
|
u64 change_attr;
|
2019-05-29 16:23:14 +00:00
|
|
|
struct timespec64 mtime, atime, ctime, btime;
|
2009-10-06 18:31:07 +00:00
|
|
|
u64 time_warp_seq;
|
2016-11-15 08:04:37 +00:00
|
|
|
u64 truncate_size;
|
|
|
|
u32 truncate_seq;
|
2009-10-06 18:31:07 +00:00
|
|
|
int writing; /* a sync write is still in progress */
|
|
|
|
int dirty_pages; /* dirty pages awaiting writeback */
|
2014-11-14 14:39:13 +00:00
|
|
|
bool inline_data;
|
2015-05-01 08:57:16 +00:00
|
|
|
bool need_flush;
|
2009-10-06 18:31:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline void ceph_put_cap_snap(struct ceph_cap_snap *capsnap)
|
|
|
|
{
|
2017-03-03 09:15:07 +00:00
|
|
|
if (refcount_dec_and_test(&capsnap->nref)) {
|
2010-08-22 22:03:56 +00:00
|
|
|
if (capsnap->xattr_blob)
|
|
|
|
ceph_buffer_put(capsnap->xattr_blob);
|
2022-02-15 12:23:14 +00:00
|
|
|
kmem_cache_free(ceph_cap_snap_cachep, capsnap);
|
2010-08-22 22:03:56 +00:00
|
|
|
}
|
2009-10-06 18:31:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The frag tree describes how a directory is fragmented, potentially across
|
|
|
|
* multiple metadata servers. It is also used to indicate points where
|
|
|
|
* metadata authority is delegated, and whether/where metadata is replicated.
|
|
|
|
*
|
|
|
|
* A _leaf_ frag will be present in the i_fragtree IFF there is
|
|
|
|
* delegation info. That is, if mds >= 0 || ndist > 0.
|
|
|
|
*/
|
|
|
|
#define CEPH_MAX_DIRFRAG_REP 4
|
|
|
|
|
|
|
|
struct ceph_inode_frag {
|
|
|
|
struct rb_node node;
|
|
|
|
|
|
|
|
/* fragtree state */
|
|
|
|
u32 frag;
|
|
|
|
int split_by; /* i.e. 2^(split_by) children */
|
|
|
|
|
|
|
|
/* delegation and replication info */
|
|
|
|
int mds; /* -1 if same authority as parent */
|
|
|
|
int ndist; /* >0 if replicated */
|
|
|
|
int dist[CEPH_MAX_DIRFRAG_REP];
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We cache inode xattrs as an encoded blob until they are first used,
|
|
|
|
* at which point we parse them into an rbtree.
|
|
|
|
*/
|
|
|
|
struct ceph_inode_xattr {
|
|
|
|
struct rb_node node;
|
|
|
|
|
|
|
|
const char *name;
|
|
|
|
int name_len;
|
|
|
|
const char *val;
|
|
|
|
int val_len;
|
|
|
|
int dirty;
|
|
|
|
|
|
|
|
int should_free_name;
|
|
|
|
int should_free_val;
|
|
|
|
};
|
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
/*
|
|
|
|
* Ceph dentry state
|
|
|
|
*/
|
|
|
|
struct ceph_dentry_info {
|
2019-01-31 08:55:51 +00:00
|
|
|
struct dentry *dentry;
|
2010-04-06 22:14:15 +00:00
|
|
|
struct ceph_mds_session *lease_session;
|
2019-01-31 08:55:51 +00:00
|
|
|
struct list_head lease_list;
|
2022-05-10 01:47:01 +00:00
|
|
|
struct hlist_node hnode;
|
|
|
|
unsigned long flags;
|
2017-11-27 02:47:46 +00:00
|
|
|
int lease_shared_gen;
|
|
|
|
u32 lease_gen;
|
2010-04-06 22:14:15 +00:00
|
|
|
u32 lease_seq;
|
|
|
|
unsigned long lease_renew_after, lease_renew_from;
|
2016-06-22 14:35:04 +00:00
|
|
|
unsigned long time;
|
2010-04-06 22:14:15 +00:00
|
|
|
u64 offset;
|
|
|
|
};
|
|
|
|
|
2022-05-10 01:47:01 +00:00
|
|
|
#define CEPH_DENTRY_REFERENCED (1 << 0)
|
|
|
|
#define CEPH_DENTRY_LEASE_LIST (1 << 1)
|
|
|
|
#define CEPH_DENTRY_SHRINK_LIST (1 << 2)
|
|
|
|
#define CEPH_DENTRY_PRIMARY_LINK (1 << 3)
|
|
|
|
#define CEPH_DENTRY_ASYNC_UNLINK_BIT (4)
|
|
|
|
#define CEPH_DENTRY_ASYNC_UNLINK (1 << CEPH_DENTRY_ASYNC_UNLINK_BIT)
|
2022-06-10 01:53:21 +00:00
|
|
|
#define CEPH_DENTRY_ASYNC_CREATE_BIT (5)
|
|
|
|
#define CEPH_DENTRY_ASYNC_CREATE (1 << CEPH_DENTRY_ASYNC_CREATE_BIT)
|
2019-01-31 08:55:51 +00:00
|
|
|
|
2009-10-06 18:31:07 +00:00
|
|
|
struct ceph_inode_xattrs_info {
|
|
|
|
/*
|
|
|
|
* (still encoded) xattr blob. we avoid the overhead of parsing
|
|
|
|
* this until someone actually calls getxattr, etc.
|
|
|
|
*
|
|
|
|
* blob->vec.iov_len == 4 implies there are no xattrs; blob ==
|
|
|
|
* NULL means we don't know.
|
|
|
|
*/
|
|
|
|
struct ceph_buffer *blob, *prealloc_blob;
|
|
|
|
|
|
|
|
struct rb_root index;
|
|
|
|
bool dirty;
|
|
|
|
int count;
|
|
|
|
int names_size;
|
|
|
|
int vals_size;
|
|
|
|
u64 version, index_version;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ceph inode.
|
|
|
|
*/
|
|
|
|
struct ceph_inode_info {
|
netfs: Fix gcc-12 warning by embedding vfs inode in netfs_i_context
While randstruct was satisfied with using an open-coded "void *" offset
cast for the netfs_i_context <-> inode casting, __builtin_object_size() as
used by FORTIFY_SOURCE was not as easily fooled. This was causing the
following complaint[1] from gcc v12:
In file included from include/linux/string.h:253,
from include/linux/ceph/ceph_debug.h:7,
from fs/ceph/inode.c:2:
In function 'fortify_memset_chk',
inlined from 'netfs_i_context_init' at include/linux/netfs.h:326:2,
inlined from 'ceph_alloc_inode' at fs/ceph/inode.c:463:2:
include/linux/fortify-string.h:242:25: warning: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Wattribute-warning]
242 | __write_overflow_field(p_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix this by embedding a struct inode into struct netfs_i_context (which
should perhaps be renamed to struct netfs_inode). The struct inode
vfs_inode fields are then removed from the 9p, afs, ceph and cifs inode
structs and vfs_inode is then simply changed to "netfs.inode" in those
filesystems.
Further, rename netfs_i_context to netfs_inode, get rid of the
netfs_inode() function that converted a netfs_i_context pointer to an
inode pointer (that can now be done with &ctx->inode) and rename the
netfs_i_context() function to netfs_inode() (which is now a wrapper
around container_of()).
Most of the changes were done with:
perl -p -i -e 's/vfs_inode/netfs.inode/'g \
`git grep -l 'vfs_inode' -- fs/{9p,afs,ceph,cifs}/*.[ch]`
Kees suggested doing it with a pair structure[2] and a special
declarator to insert that into the network filesystem's inode
wrapper[3], but I think it's cleaner to embed it - and then it doesn't
matter if struct randomisation reorders things.
Dave Chinner suggested using a filesystem-specific VFS_I() function in
each filesystem to convert that filesystem's own inode wrapper struct
into the VFS inode struct[4].
Version #2:
- Fix a couple of missed name changes due to a disabled cifs option.
- Rename nfs_i_context to nfs_inode
- Use "netfs" instead of "nic" as the member name in per-fs inode wrapper
structs.
[ This also undoes commit 507160f46c55 ("netfs: gcc-12: temporarily
disable '-Wattribute-warning' for now") that is no longer needed ]
Fixes: bc899ee1c898 ("netfs: Add a netfs inode context")
Reported-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
cc: Jonathan Corbet <corbet@lwn.net>
cc: Eric Van Hensbergen <ericvh@gmail.com>
cc: Latchesar Ionkov <lucho@ionkov.net>
cc: Dominique Martinet <asmadeus@codewreck.org>
cc: Christian Schoenebeck <linux_oss@crudebyte.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: Ilya Dryomov <idryomov@gmail.com>
cc: Steve French <smfrench@gmail.com>
cc: William Kucharski <william.kucharski@oracle.com>
cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
cc: Dave Chinner <david@fromorbit.com>
cc: linux-doc@vger.kernel.org
cc: v9fs-developer@lists.sourceforge.net
cc: linux-afs@lists.infradead.org
cc: ceph-devel@vger.kernel.org
cc: linux-cifs@vger.kernel.org
cc: samba-technical@lists.samba.org
cc: linux-fsdevel@vger.kernel.org
cc: linux-hardening@vger.kernel.org
Link: https://lore.kernel.org/r/d2ad3a3d7bdd794c6efb562d2f2b655fb67756b9.camel@kernel.org/ [1]
Link: https://lore.kernel.org/r/20220517210230.864239-1-keescook@chromium.org/ [2]
Link: https://lore.kernel.org/r/20220518202212.2322058-1-keescook@chromium.org/ [3]
Link: https://lore.kernel.org/r/20220524101205.GI2306852@dread.disaster.area/ [4]
Link: https://lore.kernel.org/r/165296786831.3591209.12111293034669289733.stgit@warthog.procyon.org.uk/ # v1
Link: https://lore.kernel.org/r/165305805651.4094995.7763502506786714216.stgit@warthog.procyon.org.uk # v2
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2022-06-09 20:46:04 +00:00
|
|
|
struct netfs_inode netfs; /* Netfslib context and vfs inode */
|
2009-10-06 18:31:07 +00:00
|
|
|
struct ceph_vino i_vino; /* ceph ino + snap */
|
|
|
|
|
2011-11-30 17:47:09 +00:00
|
|
|
spinlock_t i_ceph_lock;
|
|
|
|
|
2009-10-06 18:31:07 +00:00
|
|
|
u64 i_version;
|
2014-11-14 13:41:55 +00:00
|
|
|
u64 i_inline_version;
|
2009-10-06 18:31:07 +00:00
|
|
|
u32 i_time_warp_seq;
|
|
|
|
|
2020-01-14 20:06:40 +00:00
|
|
|
unsigned long i_ceph_flags;
|
2015-06-16 12:48:56 +00:00
|
|
|
atomic64_t i_release_count;
|
|
|
|
atomic64_t i_ordered_count;
|
|
|
|
atomic64_t i_complete_seq[2];
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2010-11-16 19:14:34 +00:00
|
|
|
struct ceph_dir_layout i_dir_layout;
|
2009-10-06 18:31:07 +00:00
|
|
|
struct ceph_file_layout i_layout;
|
2020-01-02 12:11:38 +00:00
|
|
|
struct ceph_file_layout i_cached_layout; // for async creates
|
2009-10-06 18:31:07 +00:00
|
|
|
char *i_symlink;
|
|
|
|
|
|
|
|
/* for dirs */
|
2018-07-13 20:18:36 +00:00
|
|
|
struct timespec64 i_rctime;
|
2020-08-28 01:28:44 +00:00
|
|
|
u64 i_rbytes, i_rfiles, i_rsubdirs, i_rsnaps;
|
2009-10-06 18:31:07 +00:00
|
|
|
u64 i_files, i_subdirs;
|
|
|
|
|
2018-01-05 10:47:18 +00:00
|
|
|
/* quotas */
|
|
|
|
u64 i_max_bytes, i_max_files;
|
|
|
|
|
2019-01-09 03:07:02 +00:00
|
|
|
s32 i_dir_pin;
|
|
|
|
|
2009-10-06 18:31:07 +00:00
|
|
|
struct rb_root i_fragtree;
|
2016-05-04 03:40:30 +00:00
|
|
|
int i_fragtree_nsplits;
|
2009-10-06 18:31:07 +00:00
|
|
|
struct mutex i_fragtree_mutex;
|
|
|
|
|
|
|
|
struct ceph_inode_xattrs_info i_xattrs;
|
|
|
|
|
2011-11-30 17:47:09 +00:00
|
|
|
/* capabilities. protected _both_ by i_ceph_lock and cap->session's
|
2009-10-06 18:31:07 +00:00
|
|
|
* s_mutex. */
|
|
|
|
struct rb_root i_caps; /* cap list */
|
|
|
|
struct ceph_cap *i_auth_cap; /* authoritative cap, if any */
|
|
|
|
unsigned i_dirty_caps, i_flushing_caps; /* mask of dirtied fields */
|
2020-04-01 21:07:52 +00:00
|
|
|
|
|
|
|
/*
|
2020-07-17 23:36:04 +00:00
|
|
|
* Link to the auth cap's session's s_cap_dirty list. s_cap_dirty
|
2020-04-01 21:07:52 +00:00
|
|
|
* is protected by the mdsc->cap_dirty_lock, but each individual item
|
|
|
|
* is also protected by the inode's i_ceph_lock. Walking s_cap_dirty
|
|
|
|
* requires the mdsc->cap_dirty_lock. List presence for an item can
|
|
|
|
* be tested under the i_ceph_lock. Changing anything requires both.
|
|
|
|
*/
|
|
|
|
struct list_head i_dirty_item;
|
|
|
|
|
|
|
|
/*
|
2020-04-03 17:09:07 +00:00
|
|
|
* Link to session's s_cap_flushing list. Protected in a similar
|
|
|
|
* fashion to i_dirty_item, but also by the s_mutex for changes. The
|
|
|
|
* s_cap_flushing list can be walked while holding either the s_mutex
|
|
|
|
* or msdc->cap_dirty_lock. List presence can also be checked while
|
|
|
|
* holding the i_ceph_lock for this inode.
|
2020-04-01 21:07:52 +00:00
|
|
|
*/
|
|
|
|
struct list_head i_flushing_item;
|
|
|
|
|
2009-10-06 18:31:07 +00:00
|
|
|
/* we need to track cap writeback on a per-cap-bit basis, to allow
|
|
|
|
* overlapping, pipelined cap flushes to the mds. we can probably
|
|
|
|
* reduce the tid to 8 bits if we're concerned about inode size. */
|
2015-06-10 09:26:13 +00:00
|
|
|
struct ceph_cap_flush *i_prealloc_cap_flush;
|
2016-07-06 03:12:56 +00:00
|
|
|
struct list_head i_cap_flush_list;
|
2009-10-06 18:31:07 +00:00
|
|
|
wait_queue_head_t i_cap_wq; /* threads waiting on a capability */
|
|
|
|
unsigned long i_hold_caps_max; /* jiffies */
|
|
|
|
struct list_head i_cap_delay_list; /* for delayed cap release to mds */
|
|
|
|
struct ceph_cap_reservation i_cap_migration_resv;
|
|
|
|
struct list_head i_cap_snaps; /* snapped state pending flush to mds */
|
2010-08-24 15:44:16 +00:00
|
|
|
struct ceph_snap_context *i_head_snapc; /* set if wr_buffer_head > 0 or
|
|
|
|
dirty|flushing caps */
|
2009-10-06 18:31:07 +00:00
|
|
|
unsigned i_snap_caps; /* cap bits for snapped files */
|
|
|
|
|
2020-03-05 12:21:00 +00:00
|
|
|
unsigned long i_last_rd;
|
|
|
|
unsigned long i_last_wr;
|
2016-06-06 08:01:39 +00:00
|
|
|
int i_nr_by_mode[CEPH_FILE_MODE_BITS]; /* open file counts */
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2013-08-13 04:42:15 +00:00
|
|
|
struct mutex i_truncate_mutex;
|
2009-10-06 18:31:07 +00:00
|
|
|
u32 i_truncate_seq; /* last truncate to smaller size */
|
|
|
|
u64 i_truncate_size; /* and the size we last truncated down to */
|
|
|
|
int i_truncate_pending; /* still need to call vmtruncate */
|
2022-08-25 13:31:11 +00:00
|
|
|
/*
|
|
|
|
* For none fscrypt case it equals to i_truncate_size or it will
|
|
|
|
* equals to fscrypt_file_size
|
|
|
|
*/
|
|
|
|
u64 i_truncate_pagecache_size;
|
2009-10-06 18:31:07 +00:00
|
|
|
|
|
|
|
u64 i_max_size; /* max file size authorized by mds */
|
|
|
|
u64 i_reported_size; /* (max_)size reported to or requested of mds */
|
|
|
|
u64 i_wanted_max_size; /* offset we'd like to write too */
|
|
|
|
u64 i_requested_max_size; /* max_size we've requested */
|
|
|
|
|
|
|
|
/* held references to caps */
|
|
|
|
int i_pin_ref;
|
2019-04-02 12:04:30 +00:00
|
|
|
int i_rd_ref, i_rdcache_ref, i_wr_ref, i_wb_ref, i_fx_ref;
|
2009-10-06 18:31:07 +00:00
|
|
|
int i_wrbuffer_ref, i_wrbuffer_ref_head;
|
2017-09-08 07:23:18 +00:00
|
|
|
atomic_t i_filelock_ref;
|
2017-11-27 02:47:46 +00:00
|
|
|
atomic_t i_shared_gen; /* increment each time we get FILE_SHARED */
|
2010-11-04 18:05:05 +00:00
|
|
|
u32 i_rdcache_gen; /* incremented each time we get FILE_CACHE. */
|
2009-10-06 18:31:07 +00:00
|
|
|
u32 i_rdcache_revoking; /* RDCACHE gen to async invalidate, if any */
|
|
|
|
|
|
|
|
struct list_head i_unsafe_dirops; /* uncommitted mds dir ops */
|
2015-10-27 10:36:06 +00:00
|
|
|
struct list_head i_unsafe_iops; /* uncommitted mds inode ops */
|
2009-10-06 18:31:07 +00:00
|
|
|
spinlock_t i_unsafe_lock;
|
|
|
|
|
2017-12-14 07:11:09 +00:00
|
|
|
union {
|
|
|
|
struct ceph_snap_realm *i_snap_realm; /* snap realm (if caps) */
|
|
|
|
struct ceph_snapid_map *i_snapid_map; /* snapid -> dev_t */
|
|
|
|
};
|
2009-10-06 18:31:07 +00:00
|
|
|
struct list_head i_snap_realm_item;
|
|
|
|
struct list_head i_snap_flush_item;
|
2019-05-29 15:19:42 +00:00
|
|
|
struct timespec64 i_btime;
|
2019-04-18 12:15:46 +00:00
|
|
|
struct timespec64 i_snap_btime;
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2019-05-18 03:18:44 +00:00
|
|
|
struct work_struct i_work;
|
|
|
|
unsigned long i_work_mask;
|
2020-07-27 14:16:09 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_FS_ENCRYPTION
|
|
|
|
u32 fscrypt_auth_len;
|
|
|
|
u32 fscrypt_file_len;
|
|
|
|
u8 *fscrypt_auth;
|
|
|
|
u8 *fscrypt_file;
|
|
|
|
#endif
|
2009-10-06 18:31:07 +00:00
|
|
|
};
|
|
|
|
|
2023-05-10 11:55:46 +00:00
|
|
|
struct ceph_netfs_request_data {
|
|
|
|
int caps;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Maximum size of a file readahead request.
|
|
|
|
* The fadvise could update the bdi's default ra_pages.
|
|
|
|
*/
|
|
|
|
unsigned int file_ra_pages;
|
|
|
|
|
|
|
|
/* Set it if fadvise disables file readahead entirely */
|
|
|
|
bool file_ra_disabled;
|
|
|
|
};
|
|
|
|
|
2019-08-01 18:11:15 +00:00
|
|
|
static inline struct ceph_inode_info *
|
|
|
|
ceph_inode(const struct inode *inode)
|
2009-10-06 18:31:07 +00:00
|
|
|
{
|
netfs: Fix gcc-12 warning by embedding vfs inode in netfs_i_context
While randstruct was satisfied with using an open-coded "void *" offset
cast for the netfs_i_context <-> inode casting, __builtin_object_size() as
used by FORTIFY_SOURCE was not as easily fooled. This was causing the
following complaint[1] from gcc v12:
In file included from include/linux/string.h:253,
from include/linux/ceph/ceph_debug.h:7,
from fs/ceph/inode.c:2:
In function 'fortify_memset_chk',
inlined from 'netfs_i_context_init' at include/linux/netfs.h:326:2,
inlined from 'ceph_alloc_inode' at fs/ceph/inode.c:463:2:
include/linux/fortify-string.h:242:25: warning: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Wattribute-warning]
242 | __write_overflow_field(p_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix this by embedding a struct inode into struct netfs_i_context (which
should perhaps be renamed to struct netfs_inode). The struct inode
vfs_inode fields are then removed from the 9p, afs, ceph and cifs inode
structs and vfs_inode is then simply changed to "netfs.inode" in those
filesystems.
Further, rename netfs_i_context to netfs_inode, get rid of the
netfs_inode() function that converted a netfs_i_context pointer to an
inode pointer (that can now be done with &ctx->inode) and rename the
netfs_i_context() function to netfs_inode() (which is now a wrapper
around container_of()).
Most of the changes were done with:
perl -p -i -e 's/vfs_inode/netfs.inode/'g \
`git grep -l 'vfs_inode' -- fs/{9p,afs,ceph,cifs}/*.[ch]`
Kees suggested doing it with a pair structure[2] and a special
declarator to insert that into the network filesystem's inode
wrapper[3], but I think it's cleaner to embed it - and then it doesn't
matter if struct randomisation reorders things.
Dave Chinner suggested using a filesystem-specific VFS_I() function in
each filesystem to convert that filesystem's own inode wrapper struct
into the VFS inode struct[4].
Version #2:
- Fix a couple of missed name changes due to a disabled cifs option.
- Rename nfs_i_context to nfs_inode
- Use "netfs" instead of "nic" as the member name in per-fs inode wrapper
structs.
[ This also undoes commit 507160f46c55 ("netfs: gcc-12: temporarily
disable '-Wattribute-warning' for now") that is no longer needed ]
Fixes: bc899ee1c898 ("netfs: Add a netfs inode context")
Reported-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
cc: Jonathan Corbet <corbet@lwn.net>
cc: Eric Van Hensbergen <ericvh@gmail.com>
cc: Latchesar Ionkov <lucho@ionkov.net>
cc: Dominique Martinet <asmadeus@codewreck.org>
cc: Christian Schoenebeck <linux_oss@crudebyte.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: Ilya Dryomov <idryomov@gmail.com>
cc: Steve French <smfrench@gmail.com>
cc: William Kucharski <william.kucharski@oracle.com>
cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
cc: Dave Chinner <david@fromorbit.com>
cc: linux-doc@vger.kernel.org
cc: v9fs-developer@lists.sourceforge.net
cc: linux-afs@lists.infradead.org
cc: ceph-devel@vger.kernel.org
cc: linux-cifs@vger.kernel.org
cc: samba-technical@lists.samba.org
cc: linux-fsdevel@vger.kernel.org
cc: linux-hardening@vger.kernel.org
Link: https://lore.kernel.org/r/d2ad3a3d7bdd794c6efb562d2f2b655fb67756b9.camel@kernel.org/ [1]
Link: https://lore.kernel.org/r/20220517210230.864239-1-keescook@chromium.org/ [2]
Link: https://lore.kernel.org/r/20220518202212.2322058-1-keescook@chromium.org/ [3]
Link: https://lore.kernel.org/r/20220524101205.GI2306852@dread.disaster.area/ [4]
Link: https://lore.kernel.org/r/165296786831.3591209.12111293034669289733.stgit@warthog.procyon.org.uk/ # v1
Link: https://lore.kernel.org/r/165305805651.4094995.7763502506786714216.stgit@warthog.procyon.org.uk # v2
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2022-06-09 20:46:04 +00:00
|
|
|
return container_of(inode, struct ceph_inode_info, netfs.inode);
|
2009-10-06 18:31:07 +00:00
|
|
|
}
|
|
|
|
|
2019-08-01 18:11:15 +00:00
|
|
|
static inline struct ceph_fs_client *
|
2023-06-12 02:50:38 +00:00
|
|
|
ceph_inode_to_fs_client(const struct inode *inode)
|
2011-01-22 00:44:03 +00:00
|
|
|
{
|
|
|
|
return (struct ceph_fs_client *)inode->i_sb->s_fs_info;
|
|
|
|
}
|
|
|
|
|
2019-08-01 18:11:15 +00:00
|
|
|
static inline struct ceph_fs_client *
|
2023-06-12 02:50:38 +00:00
|
|
|
ceph_sb_to_fs_client(const struct super_block *sb)
|
2011-01-22 00:44:03 +00:00
|
|
|
{
|
|
|
|
return (struct ceph_fs_client *)sb->s_fs_info;
|
|
|
|
}
|
|
|
|
|
2020-09-03 13:01:39 +00:00
|
|
|
static inline struct ceph_mds_client *
|
|
|
|
ceph_sb_to_mdsc(const struct super_block *sb)
|
|
|
|
{
|
2023-06-12 02:50:38 +00:00
|
|
|
return (struct ceph_mds_client *)ceph_sb_to_fs_client(sb)->mdsc;
|
2020-09-03 13:01:39 +00:00
|
|
|
}
|
|
|
|
|
2023-06-12 01:04:07 +00:00
|
|
|
static inline struct ceph_client *
|
|
|
|
ceph_inode_to_client(const struct inode *inode)
|
|
|
|
{
|
|
|
|
return (struct ceph_client *)ceph_inode_to_fs_client(inode)->client;
|
2020-09-03 13:01:39 +00:00
|
|
|
}
|
|
|
|
|
2019-08-01 18:11:15 +00:00
|
|
|
static inline struct ceph_vino
|
|
|
|
ceph_vino(const struct inode *inode)
|
2010-04-06 22:14:15 +00:00
|
|
|
{
|
|
|
|
return ceph_inode(inode)->i_vino;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
static inline u32 ceph_ino_to_ino32(u64 vino)
|
2011-01-22 00:44:03 +00:00
|
|
|
{
|
2011-10-20 20:04:07 +00:00
|
|
|
u32 ino = vino & 0xffffffff;
|
|
|
|
ino ^= vino >> 32;
|
2011-01-22 00:44:03 +00:00
|
|
|
if (!ino)
|
2012-01-23 17:25:23 +00:00
|
|
|
ino = 2;
|
2011-01-22 00:44:03 +00:00
|
|
|
return ino;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
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
|
|
|
* Inode numbers in cephfs are 64 bits, but inode->i_ino is 32-bits on
|
|
|
|
* some arches. We generally do not use this value inside the ceph driver, but
|
|
|
|
* we do want to set it to something, so that generic vfs code has an
|
|
|
|
* appropriate value for tracepoints and the like.
|
2010-04-06 22:14:15 +00:00
|
|
|
*/
|
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
|
|
|
static inline ino_t ceph_vino_to_ino_t(struct ceph_vino vino)
|
2010-04-06 22:14:15 +00:00
|
|
|
{
|
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
|
|
|
if (sizeof(ino_t) == sizeof(u32))
|
|
|
|
return ceph_ino_to_ino32(vino.ino);
|
2011-10-20 20:04:07 +00:00
|
|
|
return (ino_t)vino.ino;
|
2011-01-22 00:44:03 +00:00
|
|
|
}
|
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
/* for printf-style formatting */
|
|
|
|
#define ceph_vinop(i) ceph_inode(i)->i_vino.ino, ceph_inode(i)->i_vino.snap
|
|
|
|
|
|
|
|
static inline u64 ceph_ino(struct inode *inode)
|
|
|
|
{
|
|
|
|
return ceph_inode(inode)->i_vino.ino;
|
|
|
|
}
|
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
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
static inline u64 ceph_snap(struct inode *inode)
|
|
|
|
{
|
|
|
|
return ceph_inode(inode)->i_vino.snap;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
* ceph_present_ino - format an inode number for presentation to userland
|
|
|
|
* @sb: superblock where the inode lives
|
|
|
|
* @ino: inode number to (possibly) convert
|
|
|
|
*
|
|
|
|
* If the user mounted with the ino32 option, then the 64-bit value needs
|
|
|
|
* to be converted to something that can fit inside 32 bits. Note that
|
|
|
|
* internal kernel code never uses this value, so this is entirely for
|
|
|
|
* userland consumption.
|
|
|
|
*/
|
|
|
|
static inline u64 ceph_present_ino(struct super_block *sb, u64 ino)
|
|
|
|
{
|
2023-06-12 02:50:38 +00:00
|
|
|
if (unlikely(ceph_test_mount_opt(ceph_sb_to_fs_client(sb), INO32)))
|
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
|
|
|
return ceph_ino_to_ino32(ino);
|
|
|
|
return ino;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline u64 ceph_present_inode(struct inode *inode)
|
|
|
|
{
|
|
|
|
return ceph_present_ino(inode->i_sb, ceph_ino(inode));
|
|
|
|
}
|
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
static inline int ceph_ino_compare(struct inode *inode, void *data)
|
|
|
|
{
|
|
|
|
struct ceph_vino *pvino = (struct ceph_vino *)data;
|
|
|
|
struct ceph_inode_info *ci = ceph_inode(inode);
|
|
|
|
return ci->i_vino.ino == pvino->ino &&
|
|
|
|
ci->i_vino.snap == pvino->snap;
|
|
|
|
}
|
|
|
|
|
2021-04-01 17:55:11 +00:00
|
|
|
/*
|
|
|
|
* The MDS reserves a set of inodes for its own usage. These should never
|
|
|
|
* be accessible by clients, and so the MDS has no reason to ever hand these
|
|
|
|
* out. The range is CEPH_MDS_INO_MDSDIR_OFFSET..CEPH_INO_SYSTEM_BASE.
|
|
|
|
*
|
|
|
|
* These come from src/mds/mdstypes.h in the ceph sources.
|
|
|
|
*/
|
2021-11-09 14:54:49 +00:00
|
|
|
#define CEPH_MAX_MDS 0x100
|
|
|
|
#define CEPH_NUM_STRAY 10
|
2021-04-01 17:55:11 +00:00
|
|
|
#define CEPH_MDS_INO_MDSDIR_OFFSET (1 * CEPH_MAX_MDS)
|
2021-11-09 14:54:49 +00:00
|
|
|
#define CEPH_MDS_INO_LOG_OFFSET (2 * CEPH_MAX_MDS)
|
2021-04-01 17:55:11 +00:00
|
|
|
#define CEPH_INO_SYSTEM_BASE ((6*CEPH_MAX_MDS) + (CEPH_MAX_MDS * CEPH_NUM_STRAY))
|
|
|
|
|
|
|
|
static inline bool ceph_vino_is_reserved(const struct ceph_vino vino)
|
|
|
|
{
|
2021-11-09 14:54:49 +00:00
|
|
|
if (vino.ino >= CEPH_INO_SYSTEM_BASE ||
|
|
|
|
vino.ino < CEPH_MDS_INO_MDSDIR_OFFSET)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* Don't warn on mdsdirs */
|
|
|
|
WARN_RATELIMIT(vino.ino >= CEPH_MDS_INO_LOG_OFFSET,
|
|
|
|
"Attempt to access reserved inode number 0x%llx",
|
|
|
|
vino.ino);
|
|
|
|
return true;
|
2021-04-01 17:55:11 +00:00
|
|
|
}
|
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
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
static inline struct inode *ceph_find_inode(struct super_block *sb,
|
|
|
|
struct ceph_vino vino)
|
|
|
|
{
|
2021-04-01 17:55:11 +00:00
|
|
|
if (ceph_vino_is_reserved(vino))
|
|
|
|
return NULL;
|
|
|
|
|
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
|
|
|
/*
|
|
|
|
* NB: The hashval will be run through the fs/inode.c hash function
|
|
|
|
* anyway, so there is no need to squash the inode number down to
|
|
|
|
* 32-bits first. Just use low-order bits on arches with 32-bit long.
|
|
|
|
*/
|
|
|
|
return ilookup5(sb, (unsigned long)vino.ino, ceph_ino_compare, &vino);
|
2010-04-06 22:14:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ceph inode.
|
|
|
|
*/
|
2015-04-27 07:33:28 +00:00
|
|
|
#define CEPH_I_DIR_ORDERED (1 << 0) /* dentries in dir are ordered */
|
|
|
|
#define CEPH_I_FLUSH (1 << 2) /* do not delay flush of dirty metadata */
|
2019-07-05 14:55:38 +00:00
|
|
|
#define CEPH_I_POOL_PERM (1 << 3) /* pool rd/wr bits are valid */
|
|
|
|
#define CEPH_I_POOL_RD (1 << 4) /* can read from pool */
|
|
|
|
#define CEPH_I_POOL_WR (1 << 5) /* can write to pool */
|
|
|
|
#define CEPH_I_SEC_INITED (1 << 6) /* security initialized */
|
2020-03-05 12:20:59 +00:00
|
|
|
#define CEPH_I_KICK_FLUSH (1 << 7) /* kick flushing caps */
|
|
|
|
#define CEPH_I_FLUSH_SNAPS (1 << 8) /* need flush snapss */
|
|
|
|
#define CEPH_I_ERROR_WRITE (1 << 9) /* have seen write errors */
|
|
|
|
#define CEPH_I_ERROR_FILELOCK (1 << 10) /* have seen file lock errors */
|
|
|
|
#define CEPH_I_ODIRECT (1 << 11) /* inode in direct I/O mode */
|
|
|
|
#define CEPH_ASYNC_CREATE_BIT (12) /* async create in flight for this */
|
2020-01-14 20:06:40 +00:00
|
|
|
#define CEPH_I_ASYNC_CREATE (1 << CEPH_ASYNC_CREATE_BIT)
|
2021-08-31 17:39:13 +00:00
|
|
|
#define CEPH_I_SHUTDOWN (1 << 13) /* inode is no longer usable */
|
2022-10-17 14:17:35 +00:00
|
|
|
#define CEPH_I_ASYNC_CHECK_CAPS (1 << 14) /* check caps immediately after async
|
|
|
|
creating finishes */
|
2017-04-04 12:39:46 +00:00
|
|
|
|
2019-05-18 03:18:44 +00:00
|
|
|
/*
|
|
|
|
* Masks of ceph inode work.
|
|
|
|
*/
|
2020-12-10 19:39:26 +00:00
|
|
|
#define CEPH_I_WORK_WRITEBACK 0
|
|
|
|
#define CEPH_I_WORK_INVALIDATE_PAGES 1
|
|
|
|
#define CEPH_I_WORK_VMTRUNCATE 2
|
|
|
|
#define CEPH_I_WORK_CHECK_CAPS 3
|
|
|
|
#define CEPH_I_WORK_FLUSH_SNAPS 4
|
2019-05-18 03:18:44 +00:00
|
|
|
|
2017-04-04 12:39:46 +00:00
|
|
|
/*
|
|
|
|
* We set the ERROR_WRITE bit when we start seeing write errors on an inode
|
|
|
|
* and then clear it when they start succeeding. Note that we do a lockless
|
|
|
|
* check first, and only take the lock if it looks like it needs to be changed.
|
|
|
|
* The write submission code just takes this as a hint, so we're not too
|
|
|
|
* worried if a few slip through in either direction.
|
|
|
|
*/
|
|
|
|
static inline void ceph_set_error_write(struct ceph_inode_info *ci)
|
|
|
|
{
|
|
|
|
if (!(READ_ONCE(ci->i_ceph_flags) & CEPH_I_ERROR_WRITE)) {
|
|
|
|
spin_lock(&ci->i_ceph_lock);
|
|
|
|
ci->i_ceph_flags |= CEPH_I_ERROR_WRITE;
|
|
|
|
spin_unlock(&ci->i_ceph_lock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void ceph_clear_error_write(struct ceph_inode_info *ci)
|
|
|
|
{
|
|
|
|
if (READ_ONCE(ci->i_ceph_flags) & CEPH_I_ERROR_WRITE) {
|
|
|
|
spin_lock(&ci->i_ceph_lock);
|
|
|
|
ci->i_ceph_flags &= ~CEPH_I_ERROR_WRITE;
|
|
|
|
spin_unlock(&ci->i_ceph_lock);
|
|
|
|
}
|
|
|
|
}
|
2010-04-06 22:14:15 +00:00
|
|
|
|
2013-03-13 11:44:32 +00:00
|
|
|
static inline void __ceph_dir_set_complete(struct ceph_inode_info *ci,
|
2015-06-16 12:48:56 +00:00
|
|
|
long long release_count,
|
|
|
|
long long ordered_count)
|
2009-10-06 18:31:07 +00:00
|
|
|
{
|
2019-05-20 17:23:58 +00:00
|
|
|
/*
|
|
|
|
* Makes sure operations that setup readdir cache (update page
|
|
|
|
* cache and i_size) are strongly ordered w.r.t. the following
|
|
|
|
* atomic64_set() operations.
|
|
|
|
*/
|
|
|
|
smp_mb();
|
2015-06-16 12:48:56 +00:00
|
|
|
atomic64_set(&ci->i_complete_seq[0], release_count);
|
|
|
|
atomic64_set(&ci->i_complete_seq[1], ordered_count);
|
2009-10-06 18:31:07 +00:00
|
|
|
}
|
|
|
|
|
2013-03-13 11:44:32 +00:00
|
|
|
static inline void __ceph_dir_clear_complete(struct ceph_inode_info *ci)
|
2009-10-06 18:31:07 +00:00
|
|
|
{
|
2015-06-16 12:48:56 +00:00
|
|
|
atomic64_inc(&ci->i_release_count);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void __ceph_dir_clear_ordered(struct ceph_inode_info *ci)
|
|
|
|
{
|
|
|
|
atomic64_inc(&ci->i_ordered_count);
|
2013-03-13 11:44:32 +00:00
|
|
|
}
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2013-03-13 11:44:32 +00:00
|
|
|
static inline bool __ceph_dir_is_complete(struct ceph_inode_info *ci)
|
|
|
|
{
|
2015-06-16 12:48:56 +00:00
|
|
|
return atomic64_read(&ci->i_complete_seq[0]) ==
|
|
|
|
atomic64_read(&ci->i_release_count);
|
2009-10-06 18:31:07 +00:00
|
|
|
}
|
|
|
|
|
2014-10-22 01:09:56 +00:00
|
|
|
static inline bool __ceph_dir_is_complete_ordered(struct ceph_inode_info *ci)
|
|
|
|
{
|
2015-06-16 12:48:56 +00:00
|
|
|
return atomic64_read(&ci->i_complete_seq[0]) ==
|
|
|
|
atomic64_read(&ci->i_release_count) &&
|
|
|
|
atomic64_read(&ci->i_complete_seq[1]) ==
|
|
|
|
atomic64_read(&ci->i_ordered_count);
|
2014-10-22 01:09:56 +00:00
|
|
|
}
|
|
|
|
|
2013-03-13 11:44:32 +00:00
|
|
|
static inline void ceph_dir_clear_complete(struct inode *inode)
|
2009-10-06 18:31:07 +00:00
|
|
|
{
|
2013-03-13 11:44:32 +00:00
|
|
|
__ceph_dir_clear_complete(ceph_inode(inode));
|
|
|
|
}
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2014-10-22 01:09:56 +00:00
|
|
|
static inline void ceph_dir_clear_ordered(struct inode *inode)
|
2013-03-13 11:44:32 +00:00
|
|
|
{
|
2015-06-16 12:48:56 +00:00
|
|
|
__ceph_dir_clear_ordered(ceph_inode(inode));
|
2009-10-06 18:31:07 +00:00
|
|
|
}
|
|
|
|
|
2014-10-22 01:09:56 +00:00
|
|
|
static inline bool ceph_dir_is_complete_ordered(struct inode *inode)
|
|
|
|
{
|
2015-06-16 12:48:56 +00:00
|
|
|
bool ret = __ceph_dir_is_complete_ordered(ceph_inode(inode));
|
|
|
|
smp_rmb();
|
2014-10-22 01:09:56 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2009-10-06 18:31:07 +00:00
|
|
|
|
|
|
|
/* find a specific frag @f */
|
|
|
|
extern struct ceph_inode_frag *__ceph_find_frag(struct ceph_inode_info *ci,
|
|
|
|
u32 f);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* choose fragment for value @v. copy frag content to pfrag, if leaf
|
|
|
|
* exists
|
|
|
|
*/
|
|
|
|
extern u32 ceph_choose_frag(struct ceph_inode_info *ci, u32 v,
|
|
|
|
struct ceph_inode_frag *pfrag,
|
|
|
|
int *found);
|
|
|
|
|
2019-01-28 12:43:55 +00:00
|
|
|
static inline struct ceph_dentry_info *ceph_dentry(const struct dentry *dentry)
|
2009-10-06 18:31:07 +00:00
|
|
|
{
|
|
|
|
return (struct ceph_dentry_info *)dentry->d_fsdata;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* caps helpers
|
|
|
|
*/
|
|
|
|
static inline bool __ceph_is_any_real_caps(struct ceph_inode_info *ci)
|
|
|
|
{
|
|
|
|
return !RB_EMPTY_ROOT(&ci->i_caps);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern int __ceph_caps_issued(struct ceph_inode_info *ci, int *implemented);
|
|
|
|
extern int __ceph_caps_issued_mask(struct ceph_inode_info *ci, int mask, int t);
|
2020-03-20 03:45:00 +00:00
|
|
|
extern int __ceph_caps_issued_mask_metric(struct ceph_inode_info *ci, int mask,
|
|
|
|
int t);
|
2009-10-06 18:31:07 +00:00
|
|
|
extern int __ceph_caps_issued_other(struct ceph_inode_info *ci,
|
|
|
|
struct ceph_cap *cap);
|
|
|
|
|
|
|
|
static inline int ceph_caps_issued(struct ceph_inode_info *ci)
|
|
|
|
{
|
|
|
|
int issued;
|
2011-11-30 17:47:09 +00:00
|
|
|
spin_lock(&ci->i_ceph_lock);
|
2009-10-06 18:31:07 +00:00
|
|
|
issued = __ceph_caps_issued(ci, NULL);
|
2011-11-30 17:47:09 +00:00
|
|
|
spin_unlock(&ci->i_ceph_lock);
|
2009-10-06 18:31:07 +00:00
|
|
|
return issued;
|
|
|
|
}
|
|
|
|
|
2020-03-20 03:45:00 +00:00
|
|
|
static inline int ceph_caps_issued_mask_metric(struct ceph_inode_info *ci,
|
|
|
|
int mask, int touch)
|
2009-10-06 18:31:07 +00:00
|
|
|
{
|
|
|
|
int r;
|
2011-11-30 17:47:09 +00:00
|
|
|
spin_lock(&ci->i_ceph_lock);
|
2020-03-20 03:45:00 +00:00
|
|
|
r = __ceph_caps_issued_mask_metric(ci, mask, touch);
|
2011-11-30 17:47:09 +00:00
|
|
|
spin_unlock(&ci->i_ceph_lock);
|
2009-10-06 18:31:07 +00:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int __ceph_caps_dirty(struct ceph_inode_info *ci)
|
|
|
|
{
|
|
|
|
return ci->i_dirty_caps | ci->i_flushing_caps;
|
|
|
|
}
|
2015-06-10 09:26:13 +00:00
|
|
|
extern struct ceph_cap_flush *ceph_alloc_cap_flush(void);
|
|
|
|
extern void ceph_free_cap_flush(struct ceph_cap_flush *cf);
|
|
|
|
extern int __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask,
|
|
|
|
struct ceph_cap_flush **pcf);
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2013-11-22 05:50:45 +00:00
|
|
|
extern int __ceph_caps_revoking_other(struct ceph_inode_info *ci,
|
|
|
|
struct ceph_cap *ocap, int mask);
|
2009-10-06 18:31:07 +00:00
|
|
|
extern int __ceph_caps_used(struct ceph_inode_info *ci);
|
|
|
|
|
2020-03-05 12:21:00 +00:00
|
|
|
static inline bool __ceph_is_file_opened(struct ceph_inode_info *ci)
|
|
|
|
{
|
|
|
|
return ci->i_nr_by_mode[0];
|
|
|
|
}
|
2009-10-06 18:31:07 +00:00
|
|
|
extern int __ceph_caps_file_wanted(struct ceph_inode_info *ci);
|
2019-05-11 09:27:59 +00:00
|
|
|
extern int __ceph_caps_wanted(struct ceph_inode_info *ci);
|
2009-10-06 18:31:07 +00:00
|
|
|
|
|
|
|
/* what the mds thinks we want */
|
2017-01-29 14:15:47 +00:00
|
|
|
extern int __ceph_caps_mds_wanted(struct ceph_inode_info *ci, bool check);
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2010-06-17 23:16:12 +00:00
|
|
|
extern void ceph_caps_init(struct ceph_mds_client *mdsc);
|
|
|
|
extern void ceph_caps_finalize(struct ceph_mds_client *mdsc);
|
2019-02-01 06:57:15 +00:00
|
|
|
extern void ceph_adjust_caps_max_min(struct ceph_mds_client *mdsc,
|
|
|
|
struct ceph_mount_options *fsopt);
|
2018-01-24 13:24:33 +00:00
|
|
|
extern int ceph_reserve_caps(struct ceph_mds_client *mdsc,
|
2010-06-17 23:16:12 +00:00
|
|
|
struct ceph_cap_reservation *ctx, int need);
|
2018-07-28 15:15:35 +00:00
|
|
|
extern void ceph_unreserve_caps(struct ceph_mds_client *mdsc,
|
2010-06-17 23:16:12 +00:00
|
|
|
struct ceph_cap_reservation *ctx);
|
2010-04-06 22:14:15 +00:00
|
|
|
extern void ceph_reservation_status(struct ceph_fs_client *client,
|
2009-10-06 18:31:07 +00:00
|
|
|
int *total, int *avail, int *used,
|
2010-02-17 18:02:43 +00:00
|
|
|
int *reserved, int *min);
|
2022-06-10 02:12:49 +00:00
|
|
|
extern void change_auth_cap_ses(struct ceph_inode_info *ci,
|
|
|
|
struct ceph_mds_session *session);
|
2009-10-06 18:31:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* we keep buffered readdir results attached to file->private_data
|
|
|
|
*/
|
2011-07-26 18:26:07 +00:00
|
|
|
#define CEPH_F_SYNC 1
|
2011-07-26 18:26:18 +00:00
|
|
|
#define CEPH_F_ATEND 2
|
2011-07-26 18:26:07 +00:00
|
|
|
|
2009-10-06 18:31:07 +00:00
|
|
|
struct ceph_file_info {
|
2011-07-26 18:25:27 +00:00
|
|
|
short fmode; /* initialized on open */
|
|
|
|
short flags; /* CEPH_F_* */
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2017-12-15 03:15:36 +00:00
|
|
|
spinlock_t rw_contexts_lock;
|
|
|
|
struct list_head rw_contexts;
|
2019-07-25 12:16:42 +00:00
|
|
|
|
2019-07-25 12:16:46 +00:00
|
|
|
u32 filp_gen;
|
2018-03-13 02:42:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ceph_dir_file_info {
|
|
|
|
struct ceph_file_info file_info;
|
2017-12-15 03:15:36 +00:00
|
|
|
|
2009-10-06 18:31:07 +00:00
|
|
|
/* readdir: position within the dir */
|
|
|
|
u32 frag;
|
|
|
|
struct ceph_mds_request *last_readdir;
|
|
|
|
|
|
|
|
/* readdir: position within a frag */
|
2014-02-27 08:26:24 +00:00
|
|
|
unsigned next_offset; /* offset of next chunk (last_name's + 1) */
|
2009-10-06 18:31:07 +00:00
|
|
|
char *last_name; /* last entry in previous chunk */
|
2015-06-16 12:48:56 +00:00
|
|
|
long long dir_release_count;
|
|
|
|
long long dir_ordered_count;
|
|
|
|
int readdir_cache_idx;
|
2009-10-06 18:31:07 +00:00
|
|
|
|
|
|
|
/* used for -o dirstat read() on directory thing */
|
|
|
|
char *dir_info;
|
|
|
|
int dir_info_len;
|
|
|
|
};
|
|
|
|
|
2017-12-15 03:15:36 +00:00
|
|
|
struct ceph_rw_context {
|
|
|
|
struct list_head list;
|
|
|
|
struct task_struct *thread;
|
|
|
|
int caps;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define CEPH_DEFINE_RW_CONTEXT(_name, _caps) \
|
|
|
|
struct ceph_rw_context _name = { \
|
|
|
|
.thread = current, \
|
|
|
|
.caps = _caps, \
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void ceph_add_rw_context(struct ceph_file_info *cf,
|
|
|
|
struct ceph_rw_context *ctx)
|
|
|
|
{
|
|
|
|
spin_lock(&cf->rw_contexts_lock);
|
|
|
|
list_add(&ctx->list, &cf->rw_contexts);
|
|
|
|
spin_unlock(&cf->rw_contexts_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void ceph_del_rw_context(struct ceph_file_info *cf,
|
|
|
|
struct ceph_rw_context *ctx)
|
|
|
|
{
|
|
|
|
spin_lock(&cf->rw_contexts_lock);
|
|
|
|
list_del(&ctx->list);
|
|
|
|
spin_unlock(&cf->rw_contexts_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct ceph_rw_context*
|
|
|
|
ceph_find_rw_context(struct ceph_file_info *cf)
|
|
|
|
{
|
|
|
|
struct ceph_rw_context *ctx, *found = NULL;
|
|
|
|
spin_lock(&cf->rw_contexts_lock);
|
|
|
|
list_for_each_entry(ctx, &cf->rw_contexts, list) {
|
|
|
|
if (ctx->thread == current) {
|
|
|
|
found = ctx;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
spin_unlock(&cf->rw_contexts_lock);
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2015-06-16 12:48:56 +00:00
|
|
|
struct ceph_readdir_cache_control {
|
|
|
|
struct page *page;
|
|
|
|
struct dentry **dentries;
|
|
|
|
int index;
|
|
|
|
};
|
2009-10-06 18:31:07 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* A "snap realm" describes a subset of the file hierarchy sharing
|
|
|
|
* the same set of snapshots that apply to it. The realms themselves
|
|
|
|
* are organized into a hierarchy, such that children inherit (some of)
|
|
|
|
* the snapshots of their parents.
|
|
|
|
*
|
|
|
|
* All inodes within the realm that have capabilities are linked into a
|
|
|
|
* per-realm list.
|
|
|
|
*/
|
|
|
|
struct ceph_snap_realm {
|
|
|
|
u64 ino;
|
2018-01-12 17:19:28 +00:00
|
|
|
struct inode *inode;
|
2009-10-06 18:31:07 +00:00
|
|
|
atomic_t nref;
|
2010-02-15 22:37:55 +00:00
|
|
|
struct rb_node node;
|
|
|
|
|
2009-10-06 18:31:07 +00:00
|
|
|
u64 created, seq;
|
|
|
|
u64 parent_ino;
|
|
|
|
u64 parent_since; /* snapid when our current parent became so */
|
|
|
|
|
|
|
|
u64 *prior_parent_snaps; /* snaps inherited from any parents we */
|
2012-07-14 01:35:11 +00:00
|
|
|
u32 num_prior_parent_snaps; /* had prior to parent_since */
|
2009-10-06 18:31:07 +00:00
|
|
|
u64 *snaps; /* snaps specific to this realm */
|
2012-07-14 01:35:11 +00:00
|
|
|
u32 num_snaps;
|
2009-10-06 18:31:07 +00:00
|
|
|
|
|
|
|
struct ceph_snap_realm *parent;
|
|
|
|
struct list_head children; /* list of child realms */
|
|
|
|
struct list_head child_item;
|
|
|
|
|
|
|
|
struct list_head empty_item; /* if i have ref==0 */
|
|
|
|
|
2010-09-16 23:26:51 +00:00
|
|
|
struct list_head dirty_item; /* if realm needs new context */
|
|
|
|
|
2022-02-19 06:56:17 +00:00
|
|
|
struct list_head rebuild_item; /* rebuild snap realms _downward_ in hierarchy */
|
|
|
|
|
2009-10-06 18:31:07 +00:00
|
|
|
/* the current set of snaps for this realm */
|
|
|
|
struct ceph_snap_context *cached_context;
|
|
|
|
|
|
|
|
struct list_head inodes_with_caps;
|
|
|
|
spinlock_t inodes_with_caps_lock;
|
|
|
|
};
|
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
static inline int default_congestion_kb(void)
|
2009-10-06 18:31:07 +00:00
|
|
|
{
|
2010-04-06 22:14:15 +00:00
|
|
|
int congestion_kb;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copied from NFS
|
|
|
|
*
|
|
|
|
* congestion size, scale with available memory.
|
|
|
|
*
|
|
|
|
* 64MB: 8192k
|
|
|
|
* 128MB: 11585k
|
|
|
|
* 256MB: 16384k
|
|
|
|
* 512MB: 23170k
|
|
|
|
* 1GB: 32768k
|
|
|
|
* 2GB: 46340k
|
|
|
|
* 4GB: 65536k
|
|
|
|
* 8GB: 92681k
|
|
|
|
* 16GB: 131072k
|
|
|
|
*
|
|
|
|
* This allows larger machines to have larger/more transfers.
|
|
|
|
* Limit the default to 256M
|
|
|
|
*/
|
2018-12-28 08:34:29 +00:00
|
|
|
congestion_kb = (16*int_sqrt(totalram_pages())) << (PAGE_SHIFT-10);
|
2010-04-06 22:14:15 +00:00
|
|
|
if (congestion_kb > 256*1024)
|
|
|
|
congestion_kb = 256*1024;
|
|
|
|
|
|
|
|
return congestion_kb;
|
2009-10-06 18:31:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-25 12:16:44 +00:00
|
|
|
/* super.c */
|
|
|
|
extern int ceph_force_reconnect(struct super_block *sb);
|
2009-10-06 18:31:07 +00:00
|
|
|
/* snap.c */
|
|
|
|
struct ceph_snap_realm *ceph_lookup_snap_realm(struct ceph_mds_client *mdsc,
|
|
|
|
u64 ino);
|
|
|
|
extern void ceph_get_snap_realm(struct ceph_mds_client *mdsc,
|
|
|
|
struct ceph_snap_realm *realm);
|
|
|
|
extern void ceph_put_snap_realm(struct ceph_mds_client *mdsc,
|
|
|
|
struct ceph_snap_realm *realm);
|
|
|
|
extern int ceph_update_snap_trace(struct ceph_mds_client *m,
|
2014-12-23 07:30:54 +00:00
|
|
|
void *p, void *e, bool deletion,
|
|
|
|
struct ceph_snap_realm **realm_ret);
|
2021-08-02 15:01:26 +00:00
|
|
|
void ceph_change_snap_realm(struct inode *inode, struct ceph_snap_realm *realm);
|
2009-10-06 18:31:07 +00:00
|
|
|
extern void ceph_handle_snap(struct ceph_mds_client *mdsc,
|
2010-02-22 23:12:16 +00:00
|
|
|
struct ceph_mds_session *session,
|
2009-10-06 18:31:07 +00:00
|
|
|
struct ceph_msg *msg);
|
|
|
|
extern int __ceph_finish_cap_snap(struct ceph_inode_info *ci,
|
|
|
|
struct ceph_cap_snap *capsnap);
|
2022-02-23 01:04:56 +00:00
|
|
|
extern void ceph_cleanup_global_and_empty_realms(struct ceph_mds_client *mdsc);
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2017-12-14 07:11:09 +00:00
|
|
|
extern struct ceph_snapid_map *ceph_get_snapid_map(struct ceph_mds_client *mdsc,
|
|
|
|
u64 snap);
|
|
|
|
extern void ceph_put_snapid_map(struct ceph_mds_client* mdsc,
|
|
|
|
struct ceph_snapid_map *sm);
|
|
|
|
extern void ceph_trim_snapid_map(struct ceph_mds_client *mdsc);
|
|
|
|
extern void ceph_cleanup_snapid_map(struct ceph_mds_client *mdsc);
|
2021-10-14 15:10:47 +00:00
|
|
|
void ceph_umount_begin(struct super_block *sb);
|
2017-12-14 07:11:09 +00:00
|
|
|
|
|
|
|
|
2009-10-06 18:31:07 +00:00
|
|
|
/*
|
|
|
|
* a cap_snap is "pending" if it is still awaiting an in-progress
|
|
|
|
* sync write (that may/may not still update size, mtime, etc.).
|
|
|
|
*/
|
|
|
|
static inline bool __ceph_have_pending_cap_snap(struct ceph_inode_info *ci)
|
|
|
|
{
|
|
|
|
return !list_empty(&ci->i_cap_snaps) &&
|
2015-05-01 08:57:16 +00:00
|
|
|
list_last_entry(&ci->i_cap_snaps, struct ceph_cap_snap,
|
|
|
|
ci_item)->writing;
|
2009-10-06 18:31:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* inode.c */
|
2019-12-05 14:09:25 +00:00
|
|
|
struct ceph_mds_reply_info_in;
|
|
|
|
struct ceph_mds_reply_dirfrag;
|
ceph: preallocate inode for ops that may create one
When creating a new inode, we need to determine the crypto context
before we can transmit the RPC. The fscrypt API has a routine for getting
a crypto context before a create occurs, but it requires an inode.
Change the ceph code to preallocate an inode in advance of a create of
any sort (open(), mknod(), symlink(), etc). Move the existing code that
generates the ACL and SELinux blobs into this routine since that's
mostly common across all the different codepaths.
In most cases, we just want to allow ceph_fill_trace to use that inode
after the reply comes in, so add a new field to the MDS request for it
(r_new_inode).
The async create codepath is a bit different though. In that case, we
want to hash the inode in advance of the RPC so that it can be used
before the reply comes in. If the call subsequently fails with
-EJUKEBOX, then just put the references and clean up the as_ctx. Note
that with this change, we now need to regenerate the as_ctx when this
occurs, but it's quite rare for it to happen.
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Reviewed-and-tested-by: Luís Henriques <lhenriques@suse.de>
Reviewed-by: Milind Changire <mchangir@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
2020-08-26 17:11:00 +00:00
|
|
|
struct ceph_acl_sec_ctx;
|
2019-12-05 14:09:25 +00:00
|
|
|
|
2009-10-06 18:31:07 +00:00
|
|
|
extern const struct inode_operations ceph_file_iops;
|
|
|
|
|
|
|
|
extern struct inode *ceph_alloc_inode(struct super_block *sb);
|
2019-06-02 01:45:38 +00:00
|
|
|
extern void ceph_evict_inode(struct inode *inode);
|
2019-04-10 19:18:50 +00:00
|
|
|
extern void ceph_free_inode(struct inode *inode);
|
2009-10-06 18:31:07 +00:00
|
|
|
|
ceph: preallocate inode for ops that may create one
When creating a new inode, we need to determine the crypto context
before we can transmit the RPC. The fscrypt API has a routine for getting
a crypto context before a create occurs, but it requires an inode.
Change the ceph code to preallocate an inode in advance of a create of
any sort (open(), mknod(), symlink(), etc). Move the existing code that
generates the ACL and SELinux blobs into this routine since that's
mostly common across all the different codepaths.
In most cases, we just want to allow ceph_fill_trace to use that inode
after the reply comes in, so add a new field to the MDS request for it
(r_new_inode).
The async create codepath is a bit different though. In that case, we
want to hash the inode in advance of the RPC so that it can be used
before the reply comes in. If the call subsequently fails with
-EJUKEBOX, then just put the references and clean up the as_ctx. Note
that with this change, we now need to regenerate the as_ctx when this
occurs, but it's quite rare for it to happen.
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Reviewed-and-tested-by: Luís Henriques <lhenriques@suse.de>
Reviewed-by: Milind Changire <mchangir@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
2020-08-26 17:11:00 +00:00
|
|
|
struct inode *ceph_new_inode(struct inode *dir, struct dentry *dentry,
|
|
|
|
umode_t *mode, struct ceph_acl_sec_ctx *as_ctx);
|
|
|
|
void ceph_as_ctx_to_req(struct ceph_mds_request *req,
|
|
|
|
struct ceph_acl_sec_ctx *as_ctx);
|
|
|
|
|
2009-10-06 18:31:07 +00:00
|
|
|
extern struct inode *ceph_get_inode(struct super_block *sb,
|
ceph: preallocate inode for ops that may create one
When creating a new inode, we need to determine the crypto context
before we can transmit the RPC. The fscrypt API has a routine for getting
a crypto context before a create occurs, but it requires an inode.
Change the ceph code to preallocate an inode in advance of a create of
any sort (open(), mknod(), symlink(), etc). Move the existing code that
generates the ACL and SELinux blobs into this routine since that's
mostly common across all the different codepaths.
In most cases, we just want to allow ceph_fill_trace to use that inode
after the reply comes in, so add a new field to the MDS request for it
(r_new_inode).
The async create codepath is a bit different though. In that case, we
want to hash the inode in advance of the RPC so that it can be used
before the reply comes in. If the call subsequently fails with
-EJUKEBOX, then just put the references and clean up the as_ctx. Note
that with this change, we now need to regenerate the as_ctx when this
occurs, but it's quite rare for it to happen.
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Reviewed-and-tested-by: Luís Henriques <lhenriques@suse.de>
Reviewed-by: Milind Changire <mchangir@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
2020-08-26 17:11:00 +00:00
|
|
|
struct ceph_vino vino,
|
|
|
|
struct inode *newino);
|
2009-10-06 18:31:07 +00:00
|
|
|
extern struct inode *ceph_get_snapdir(struct inode *parent);
|
|
|
|
extern int ceph_fill_file_size(struct inode *inode, int issued,
|
|
|
|
u32 truncate_seq, u64 truncate_size, u64 size);
|
|
|
|
extern void ceph_fill_file_time(struct inode *inode, int issued,
|
2018-07-13 20:18:36 +00:00
|
|
|
u64 time_warp_seq, struct timespec64 *ctime,
|
|
|
|
struct timespec64 *mtime,
|
|
|
|
struct timespec64 *atime);
|
2019-12-05 14:09:25 +00:00
|
|
|
extern int ceph_fill_inode(struct inode *inode, struct page *locked_page,
|
|
|
|
struct ceph_mds_reply_info_in *iinfo,
|
|
|
|
struct ceph_mds_reply_dirfrag *dirinfo,
|
|
|
|
struct ceph_mds_session *session, int cap_fmode,
|
|
|
|
struct ceph_cap_reservation *caps_reservation);
|
2009-10-06 18:31:07 +00:00
|
|
|
extern int ceph_fill_trace(struct super_block *sb,
|
2017-01-31 16:06:13 +00:00
|
|
|
struct ceph_mds_request *req);
|
2009-10-06 18:31:07 +00:00
|
|
|
extern int ceph_readdir_prepopulate(struct ceph_mds_request *req,
|
|
|
|
struct ceph_mds_session *session);
|
|
|
|
|
2017-05-22 04:03:32 +00:00
|
|
|
extern bool ceph_inode_set_size(struct inode *inode, loff_t size);
|
2013-07-02 04:40:19 +00:00
|
|
|
extern void __ceph_do_pending_vmtruncate(struct inode *inode);
|
2020-10-09 18:24:34 +00:00
|
|
|
|
|
|
|
void ceph_queue_inode_work(struct inode *inode, int work_bit);
|
|
|
|
|
|
|
|
static inline void ceph_queue_vmtruncate(struct inode *inode)
|
|
|
|
{
|
|
|
|
ceph_queue_inode_work(inode, CEPH_I_WORK_VMTRUNCATE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void ceph_queue_invalidate(struct inode *inode)
|
|
|
|
{
|
|
|
|
ceph_queue_inode_work(inode, CEPH_I_WORK_INVALIDATE_PAGES);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void ceph_queue_writeback(struct inode *inode)
|
|
|
|
{
|
|
|
|
ceph_queue_inode_work(inode, CEPH_I_WORK_WRITEBACK);
|
|
|
|
}
|
|
|
|
|
2020-12-10 19:39:26 +00:00
|
|
|
static inline void ceph_queue_check_caps(struct inode *inode)
|
|
|
|
{
|
|
|
|
ceph_queue_inode_work(inode, CEPH_I_WORK_CHECK_CAPS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void ceph_queue_flush_snaps(struct inode *inode)
|
|
|
|
{
|
|
|
|
ceph_queue_inode_work(inode, CEPH_I_WORK_FLUSH_SNAPS);
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:26:40 +00:00
|
|
|
extern int ceph_try_to_choose_auth_mds(struct inode *inode, int mask);
|
2014-11-14 13:56:29 +00:00
|
|
|
extern int __ceph_do_getattr(struct inode *inode, struct page *locked_page,
|
|
|
|
int mask, bool force);
|
|
|
|
static inline int ceph_do_getattr(struct inode *inode, int mask, bool force)
|
|
|
|
{
|
|
|
|
return __ceph_do_getattr(inode, NULL, mask, force);
|
|
|
|
}
|
2023-01-13 11:49:22 +00:00
|
|
|
extern int ceph_permission(struct mnt_idmap *idmap,
|
2021-01-21 13:19:43 +00:00
|
|
|
struct inode *inode, int mask);
|
2020-07-27 14:16:09 +00:00
|
|
|
|
|
|
|
struct ceph_iattr {
|
|
|
|
struct ceph_fscrypt_auth *fscrypt_auth;
|
|
|
|
};
|
|
|
|
|
2023-08-07 13:26:22 +00:00
|
|
|
extern int __ceph_setattr(struct mnt_idmap *idmap, struct inode *inode,
|
|
|
|
struct iattr *attr, struct ceph_iattr *cia);
|
2023-01-13 11:49:11 +00:00
|
|
|
extern int ceph_setattr(struct mnt_idmap *idmap,
|
2021-01-21 13:19:43 +00:00
|
|
|
struct dentry *dentry, struct iattr *attr);
|
2023-01-13 11:49:12 +00:00
|
|
|
extern int ceph_getattr(struct mnt_idmap *idmap,
|
2021-01-21 13:19:43 +00:00
|
|
|
const struct path *path, struct kstat *stat,
|
statx: Add a system call to make enhanced file info available
Add a system call to make extended file information available, including
file creation and some attribute flags where available through the
underlying filesystem.
The getattr inode operation is altered to take two additional arguments: a
u32 request_mask and an unsigned int flags that indicate the
synchronisation mode. This change is propagated to the vfs_getattr*()
function.
Functions like vfs_stat() are now inline wrappers around new functions
vfs_statx() and vfs_statx_fd() to reduce stack usage.
========
OVERVIEW
========
The idea was initially proposed as a set of xattrs that could be retrieved
with getxattr(), but the general preference proved to be for a new syscall
with an extended stat structure.
A number of requests were gathered for features to be included. The
following have been included:
(1) Make the fields a consistent size on all arches and make them large.
(2) Spare space, request flags and information flags are provided for
future expansion.
(3) Better support for the y2038 problem [Arnd Bergmann] (tv_sec is an
__s64).
(4) Creation time: The SMB protocol carries the creation time, which could
be exported by Samba, which will in turn help CIFS make use of
FS-Cache as that can be used for coherency data (stx_btime).
This is also specified in NFSv4 as a recommended attribute and could
be exported by NFSD [Steve French].
(5) Lightweight stat: Ask for just those details of interest, and allow a
netfs (such as NFS) to approximate anything not of interest, possibly
without going to the server [Trond Myklebust, Ulrich Drepper, Andreas
Dilger] (AT_STATX_DONT_SYNC).
(6) Heavyweight stat: Force a netfs to go to the server, even if it thinks
its cached attributes are up to date [Trond Myklebust]
(AT_STATX_FORCE_SYNC).
And the following have been left out for future extension:
(7) Data version number: Could be used by userspace NFS servers [Aneesh
Kumar].
Can also be used to modify fill_post_wcc() in NFSD which retrieves
i_version directly, but has just called vfs_getattr(). It could get
it from the kstat struct if it used vfs_xgetattr() instead.
(There's disagreement on the exact semantics of a single field, since
not all filesystems do this the same way).
(8) BSD stat compatibility: Including more fields from the BSD stat such
as creation time (st_btime) and inode generation number (st_gen)
[Jeremy Allison, Bernd Schubert].
(9) Inode generation number: Useful for FUSE and userspace NFS servers
[Bernd Schubert].
(This was asked for but later deemed unnecessary with the
open-by-handle capability available and caused disagreement as to
whether it's a security hole or not).
(10) Extra coherency data may be useful in making backups [Andreas Dilger].
(No particular data were offered, but things like last backup
timestamp, the data version number and the DOS archive bit would come
into this category).
(11) Allow the filesystem to indicate what it can/cannot provide: A
filesystem can now say it doesn't support a standard stat feature if
that isn't available, so if, for instance, inode numbers or UIDs don't
exist or are fabricated locally...
(This requires a separate system call - I have an fsinfo() call idea
for this).
(12) Store a 16-byte volume ID in the superblock that can be returned in
struct xstat [Steve French].
(Deferred to fsinfo).
(13) Include granularity fields in the time data to indicate the
granularity of each of the times (NFSv4 time_delta) [Steve French].
(Deferred to fsinfo).
(14) FS_IOC_GETFLAGS value. These could be translated to BSD's st_flags.
Note that the Linux IOC flags are a mess and filesystems such as Ext4
define flags that aren't in linux/fs.h, so translation in the kernel
may be a necessity (or, possibly, we provide the filesystem type too).
(Some attributes are made available in stx_attributes, but the general
feeling was that the IOC flags were to ext[234]-specific and shouldn't
be exposed through statx this way).
(15) Mask of features available on file (eg: ACLs, seclabel) [Brad Boyer,
Michael Kerrisk].
(Deferred, probably to fsinfo. Finding out if there's an ACL or
seclabal might require extra filesystem operations).
(16) Femtosecond-resolution timestamps [Dave Chinner].
(A __reserved field has been left in the statx_timestamp struct for
this - if there proves to be a need).
(17) A set multiple attributes syscall to go with this.
===============
NEW SYSTEM CALL
===============
The new system call is:
int ret = statx(int dfd,
const char *filename,
unsigned int flags,
unsigned int mask,
struct statx *buffer);
The dfd, filename and flags parameters indicate the file to query, in a
similar way to fstatat(). There is no equivalent of lstat() as that can be
emulated with statx() by passing AT_SYMLINK_NOFOLLOW in flags. There is
also no equivalent of fstat() as that can be emulated by passing a NULL
filename to statx() with the fd of interest in dfd.
Whether or not statx() synchronises the attributes with the backing store
can be controlled by OR'ing a value into the flags argument (this typically
only affects network filesystems):
(1) AT_STATX_SYNC_AS_STAT tells statx() to behave as stat() does in this
respect.
(2) AT_STATX_FORCE_SYNC will require a network filesystem to synchronise
its attributes with the server - which might require data writeback to
occur to get the timestamps correct.
(3) AT_STATX_DONT_SYNC will suppress synchronisation with the server in a
network filesystem. The resulting values should be considered
approximate.
mask is a bitmask indicating the fields in struct statx that are of
interest to the caller. The user should set this to STATX_BASIC_STATS to
get the basic set returned by stat(). It should be noted that asking for
more information may entail extra I/O operations.
buffer points to the destination for the data. This must be 256 bytes in
size.
======================
MAIN ATTRIBUTES RECORD
======================
The following structures are defined in which to return the main attribute
set:
struct statx_timestamp {
__s64 tv_sec;
__s32 tv_nsec;
__s32 __reserved;
};
struct statx {
__u32 stx_mask;
__u32 stx_blksize;
__u64 stx_attributes;
__u32 stx_nlink;
__u32 stx_uid;
__u32 stx_gid;
__u16 stx_mode;
__u16 __spare0[1];
__u64 stx_ino;
__u64 stx_size;
__u64 stx_blocks;
__u64 __spare1[1];
struct statx_timestamp stx_atime;
struct statx_timestamp stx_btime;
struct statx_timestamp stx_ctime;
struct statx_timestamp stx_mtime;
__u32 stx_rdev_major;
__u32 stx_rdev_minor;
__u32 stx_dev_major;
__u32 stx_dev_minor;
__u64 __spare2[14];
};
The defined bits in request_mask and stx_mask are:
STATX_TYPE Want/got stx_mode & S_IFMT
STATX_MODE Want/got stx_mode & ~S_IFMT
STATX_NLINK Want/got stx_nlink
STATX_UID Want/got stx_uid
STATX_GID Want/got stx_gid
STATX_ATIME Want/got stx_atime{,_ns}
STATX_MTIME Want/got stx_mtime{,_ns}
STATX_CTIME Want/got stx_ctime{,_ns}
STATX_INO Want/got stx_ino
STATX_SIZE Want/got stx_size
STATX_BLOCKS Want/got stx_blocks
STATX_BASIC_STATS [The stuff in the normal stat struct]
STATX_BTIME Want/got stx_btime{,_ns}
STATX_ALL [All currently available stuff]
stx_btime is the file creation time, stx_mask is a bitmask indicating the
data provided and __spares*[] are where as-yet undefined fields can be
placed.
Time fields are structures with separate seconds and nanoseconds fields
plus a reserved field in case we want to add even finer resolution. Note
that times will be negative if before 1970; in such a case, the nanosecond
fields will also be negative if not zero.
The bits defined in the stx_attributes field convey information about a
file, how it is accessed, where it is and what it does. The following
attributes map to FS_*_FL flags and are the same numerical value:
STATX_ATTR_COMPRESSED File is compressed by the fs
STATX_ATTR_IMMUTABLE File is marked immutable
STATX_ATTR_APPEND File is append-only
STATX_ATTR_NODUMP File is not to be dumped
STATX_ATTR_ENCRYPTED File requires key to decrypt in fs
Within the kernel, the supported flags are listed by:
KSTAT_ATTR_FS_IOC_FLAGS
[Are any other IOC flags of sufficient general interest to be exposed
through this interface?]
New flags include:
STATX_ATTR_AUTOMOUNT Object is an automount trigger
These are for the use of GUI tools that might want to mark files specially,
depending on what they are.
Fields in struct statx come in a number of classes:
(0) stx_dev_*, stx_blksize.
These are local system information and are always available.
(1) stx_mode, stx_nlinks, stx_uid, stx_gid, stx_[amc]time, stx_ino,
stx_size, stx_blocks.
These will be returned whether the caller asks for them or not. The
corresponding bits in stx_mask will be set to indicate whether they
actually have valid values.
If the caller didn't ask for them, then they may be approximated. For
example, NFS won't waste any time updating them from the server,
unless as a byproduct of updating something requested.
If the values don't actually exist for the underlying object (such as
UID or GID on a DOS file), then the bit won't be set in the stx_mask,
even if the caller asked for the value. In such a case, the returned
value will be a fabrication.
Note that there are instances where the type might not be valid, for
instance Windows reparse points.
(2) stx_rdev_*.
This will be set only if stx_mode indicates we're looking at a
blockdev or a chardev, otherwise will be 0.
(3) stx_btime.
Similar to (1), except this will be set to 0 if it doesn't exist.
=======
TESTING
=======
The following test program can be used to test the statx system call:
samples/statx/test-statx.c
Just compile and run, passing it paths to the files you want to examine.
The file is built automatically if CONFIG_SAMPLES is enabled.
Here's some example output. Firstly, an NFS directory that crosses to
another FSID. Note that the AUTOMOUNT attribute is set because transiting
this directory will cause d_automount to be invoked by the VFS.
[root@andromeda ~]# /tmp/test-statx -A /warthog/data
statx(/warthog/data) = 0
results=7ff
Size: 4096 Blocks: 8 IO Block: 1048576 directory
Device: 00:26 Inode: 1703937 Links: 125
Access: (3777/drwxrwxrwx) Uid: 0 Gid: 4041
Access: 2016-11-24 09:02:12.219699527+0000
Modify: 2016-11-17 10:44:36.225653653+0000
Change: 2016-11-17 10:44:36.225653653+0000
Attributes: 0000000000001000 (-------- -------- -------- -------- -------- -------- ---m---- --------)
Secondly, the result of automounting on that directory.
[root@andromeda ~]# /tmp/test-statx /warthog/data
statx(/warthog/data) = 0
results=7ff
Size: 4096 Blocks: 8 IO Block: 1048576 directory
Device: 00:27 Inode: 2 Links: 125
Access: (3777/drwxrwxrwx) Uid: 0 Gid: 4041
Access: 2016-11-24 09:02:12.219699527+0000
Modify: 2016-11-17 10:44:36.225653653+0000
Change: 2016-11-17 10:44:36.225653653+0000
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2017-01-31 16:46:22 +00:00
|
|
|
u32 request_mask, unsigned int flags);
|
2021-08-31 17:39:13 +00:00
|
|
|
void ceph_inode_shutdown(struct inode *inode);
|
|
|
|
|
|
|
|
static inline bool ceph_inode_is_shutdown(struct inode *inode)
|
|
|
|
{
|
|
|
|
unsigned long flags = READ_ONCE(ceph_inode(inode)->i_ceph_flags);
|
2023-06-12 02:50:38 +00:00
|
|
|
struct ceph_fs_client *fsc = ceph_inode_to_fs_client(inode);
|
2021-08-31 17:39:13 +00:00
|
|
|
int state = READ_ONCE(fsc->mount_state);
|
|
|
|
|
|
|
|
return (flags & CEPH_I_SHUTDOWN) || state >= CEPH_MOUNT_SHUTDOWN;
|
|
|
|
}
|
2009-10-06 18:31:07 +00:00
|
|
|
|
|
|
|
/* xattr.c */
|
2016-04-13 22:30:16 +00:00
|
|
|
int __ceph_setxattr(struct inode *, const char *, const void *, size_t, int);
|
2022-02-14 05:01:01 +00:00
|
|
|
int ceph_do_getvxattr(struct inode *inode, const char *name, void *value, size_t size);
|
2013-11-11 07:18:03 +00:00
|
|
|
ssize_t __ceph_getxattr(struct inode *, const char *, void *, size_t);
|
2009-10-06 18:31:07 +00:00
|
|
|
extern ssize_t ceph_listxattr(struct dentry *, char *, size_t);
|
2019-07-19 14:32:21 +00:00
|
|
|
extern struct ceph_buffer *__ceph_build_xattrs_blob(struct ceph_inode_info *ci);
|
2009-10-06 18:31:07 +00:00
|
|
|
extern void __ceph_destroy_xattrs(struct ceph_inode_info *ci);
|
2023-09-30 05:00:10 +00:00
|
|
|
extern const struct xattr_handler * const ceph_xattr_handlers[];
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2019-05-26 07:35:39 +00:00
|
|
|
struct ceph_acl_sec_ctx {
|
|
|
|
#ifdef CONFIG_CEPH_FS_POSIX_ACL
|
|
|
|
void *default_acl;
|
|
|
|
void *acl;
|
2019-05-26 08:27:56 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_CEPH_FS_SECURITY_LABEL
|
2024-10-23 21:21:57 +00:00
|
|
|
struct lsm_context lsmctx;
|
2020-09-08 13:47:40 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_FS_ENCRYPTION
|
|
|
|
struct ceph_fscrypt_auth *fscrypt_auth;
|
2019-05-26 07:35:39 +00:00
|
|
|
#endif
|
|
|
|
struct ceph_pagelist *pagelist;
|
|
|
|
};
|
|
|
|
|
2016-03-07 02:34:50 +00:00
|
|
|
#ifdef CONFIG_SECURITY
|
|
|
|
extern bool ceph_security_xattr_deadlock(struct inode *in);
|
|
|
|
extern bool ceph_security_xattr_wanted(struct inode *in);
|
|
|
|
#else
|
|
|
|
static inline bool ceph_security_xattr_deadlock(struct inode *in)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
static inline bool ceph_security_xattr_wanted(struct inode *in)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-05-26 08:27:56 +00:00
|
|
|
#ifdef CONFIG_CEPH_FS_SECURITY_LABEL
|
|
|
|
extern int ceph_security_init_secctx(struct dentry *dentry, umode_t mode,
|
|
|
|
struct ceph_acl_sec_ctx *ctx);
|
2019-08-06 13:07:51 +00:00
|
|
|
static inline void ceph_security_invalidate_secctx(struct inode *inode)
|
|
|
|
{
|
|
|
|
security_inode_invalidate_secctx(inode);
|
|
|
|
}
|
2019-05-26 08:27:56 +00:00
|
|
|
#else
|
|
|
|
static inline int ceph_security_init_secctx(struct dentry *dentry, umode_t mode,
|
|
|
|
struct ceph_acl_sec_ctx *ctx)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static inline void ceph_security_invalidate_secctx(struct inode *inode)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-05-26 07:35:39 +00:00
|
|
|
void ceph_release_acl_sec_ctx(struct ceph_acl_sec_ctx *as_ctx);
|
2013-11-11 07:18:03 +00:00
|
|
|
|
2019-05-26 07:35:39 +00:00
|
|
|
/* acl.c */
|
2013-11-11 07:18:03 +00:00
|
|
|
#ifdef CONFIG_CEPH_FS_POSIX_ACL
|
|
|
|
|
2021-08-18 20:08:24 +00:00
|
|
|
struct posix_acl *ceph_get_acl(struct inode *, int, bool);
|
2023-01-13 11:49:20 +00:00
|
|
|
int ceph_set_acl(struct mnt_idmap *idmap,
|
2022-09-23 08:29:39 +00:00
|
|
|
struct dentry *dentry, struct posix_acl *acl, int type);
|
2014-09-16 12:35:17 +00:00
|
|
|
int ceph_pre_init_acls(struct inode *dir, umode_t *mode,
|
2019-05-26 07:35:39 +00:00
|
|
|
struct ceph_acl_sec_ctx *as_ctx);
|
|
|
|
void ceph_init_inode_acls(struct inode *inode,
|
|
|
|
struct ceph_acl_sec_ctx *as_ctx);
|
2014-02-16 16:35:52 +00:00
|
|
|
|
|
|
|
static inline void ceph_forget_all_cached_acls(struct inode *inode)
|
|
|
|
{
|
|
|
|
forget_all_cached_acls(inode);
|
|
|
|
}
|
2013-11-11 07:18:03 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define ceph_get_acl NULL
|
2014-01-29 14:22:25 +00:00
|
|
|
#define ceph_set_acl NULL
|
2013-11-11 07:18:03 +00:00
|
|
|
|
2014-09-16 12:35:17 +00:00
|
|
|
static inline int ceph_pre_init_acls(struct inode *dir, umode_t *mode,
|
2019-05-26 07:35:39 +00:00
|
|
|
struct ceph_acl_sec_ctx *as_ctx)
|
2013-11-11 07:18:03 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2014-09-16 12:35:17 +00:00
|
|
|
static inline void ceph_init_inode_acls(struct inode *inode,
|
2019-05-26 07:35:39 +00:00
|
|
|
struct ceph_acl_sec_ctx *as_ctx)
|
2014-09-16 12:35:17 +00:00
|
|
|
{
|
|
|
|
}
|
2013-11-11 07:18:03 +00:00
|
|
|
|
|
|
|
static inline void ceph_forget_all_cached_acls(struct inode *inode)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2009-10-06 18:31:07 +00:00
|
|
|
/* caps.c */
|
|
|
|
extern const char *ceph_cap_string(int c);
|
|
|
|
extern void ceph_handle_caps(struct ceph_mds_session *session,
|
|
|
|
struct ceph_msg *msg);
|
2014-04-18 01:57:11 +00:00
|
|
|
extern struct ceph_cap *ceph_get_cap(struct ceph_mds_client *mdsc,
|
|
|
|
struct ceph_cap_reservation *ctx);
|
|
|
|
extern void ceph_add_cap(struct inode *inode,
|
|
|
|
struct ceph_mds_session *session, u64 cap_id,
|
2020-03-05 12:21:02 +00:00
|
|
|
unsigned issued, unsigned wanted,
|
2014-04-18 01:57:11 +00:00
|
|
|
unsigned cap, unsigned seq, u64 realmino, int flags,
|
|
|
|
struct ceph_cap **new_cap);
|
2013-09-22 02:15:58 +00:00
|
|
|
extern void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release);
|
2023-06-09 07:15:47 +00:00
|
|
|
extern void ceph_remove_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap,
|
|
|
|
bool queue_release);
|
2019-05-23 03:01:37 +00:00
|
|
|
extern void __ceph_remove_caps(struct ceph_inode_info *ci);
|
2010-06-17 23:16:12 +00:00
|
|
|
extern void ceph_put_cap(struct ceph_mds_client *mdsc,
|
|
|
|
struct ceph_cap *cap);
|
2013-11-30 04:47:41 +00:00
|
|
|
extern int ceph_is_any_caps(struct inode *inode);
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2010-01-18 00:53:08 +00:00
|
|
|
extern int ceph_write_inode(struct inode *inode, struct writeback_control *wbc);
|
2011-07-17 00:44:56 +00:00
|
|
|
extern int ceph_fsync(struct file *file, loff_t start, loff_t end,
|
|
|
|
int datasync);
|
2015-06-10 07:17:56 +00:00
|
|
|
extern void ceph_early_kick_flushing_caps(struct ceph_mds_client *mdsc,
|
|
|
|
struct ceph_mds_session *session);
|
2009-10-06 18:31:07 +00:00
|
|
|
extern void ceph_kick_flushing_caps(struct ceph_mds_client *mdsc,
|
|
|
|
struct ceph_mds_session *session);
|
2020-02-25 19:49:53 +00:00
|
|
|
void ceph_kick_flushing_inode_caps(struct ceph_mds_session *session,
|
|
|
|
struct ceph_inode_info *ci);
|
2023-04-19 02:39:14 +00:00
|
|
|
extern struct ceph_cap *__get_cap_for_mds(struct ceph_inode_info *ci,
|
|
|
|
int mds);
|
2010-06-30 19:44:34 +00:00
|
|
|
extern struct ceph_cap *ceph_get_cap_for_mds(struct ceph_inode_info *ci,
|
|
|
|
int mds);
|
2020-01-14 14:23:49 +00:00
|
|
|
extern void ceph_take_cap_refs(struct ceph_inode_info *ci, int caps,
|
|
|
|
bool snap_rwsem_locked);
|
2009-10-06 18:31:07 +00:00
|
|
|
extern void ceph_get_cap_refs(struct ceph_inode_info *ci, int caps);
|
|
|
|
extern void ceph_put_cap_refs(struct ceph_inode_info *ci, int had);
|
2020-12-10 19:39:26 +00:00
|
|
|
extern void ceph_put_cap_refs_async(struct ceph_inode_info *ci, int had);
|
2009-10-06 18:31:07 +00:00
|
|
|
extern void ceph_put_wrbuffer_cap_refs(struct ceph_inode_info *ci, int nr,
|
|
|
|
struct ceph_snap_context *snapc);
|
2021-08-25 13:45:43 +00:00
|
|
|
extern void __ceph_remove_capsnap(struct inode *inode,
|
|
|
|
struct ceph_cap_snap *capsnap,
|
|
|
|
bool *wake_ci, bool *wake_mdsc);
|
|
|
|
extern void ceph_remove_capsnap(struct inode *inode,
|
|
|
|
struct ceph_cap_snap *capsnap,
|
|
|
|
bool *wake_ci, bool *wake_mdsc);
|
2016-07-05 13:08:07 +00:00
|
|
|
extern void ceph_flush_snaps(struct ceph_inode_info *ci,
|
|
|
|
struct ceph_mds_session **psession);
|
2017-05-22 04:03:32 +00:00
|
|
|
extern bool __ceph_should_report_size(struct ceph_inode_info *ci);
|
2022-10-18 01:03:29 +00:00
|
|
|
extern void ceph_check_caps(struct ceph_inode_info *ci, int flags);
|
2021-07-06 13:52:41 +00:00
|
|
|
extern unsigned long ceph_check_delayed_caps(struct ceph_mds_client *mdsc);
|
2009-10-14 21:27:38 +00:00
|
|
|
extern void ceph_flush_dirty_caps(struct ceph_mds_client *mdsc);
|
2024-07-29 08:04:11 +00:00
|
|
|
extern void ceph_flush_cap_releases(struct ceph_mds_client *mdsc);
|
2018-01-24 13:24:33 +00:00
|
|
|
extern int ceph_drop_caps_for_unlink(struct inode *inode);
|
2009-10-06 18:31:07 +00:00
|
|
|
extern int ceph_encode_inode_release(void **p, struct inode *inode,
|
|
|
|
int mds, int drop, int unless, int force);
|
|
|
|
extern int ceph_encode_dentry_release(void **p, struct dentry *dn,
|
2016-12-15 13:37:59 +00:00
|
|
|
struct inode *dir,
|
2009-10-06 18:31:07 +00:00
|
|
|
int mds, int drop, int unless);
|
|
|
|
|
2022-08-25 13:31:11 +00:00
|
|
|
extern int __ceph_get_caps(struct inode *inode, struct ceph_file_info *fi,
|
|
|
|
int need, int want, loff_t endoff, int *got);
|
2019-07-25 12:16:43 +00:00
|
|
|
extern int ceph_get_caps(struct file *filp, int need, int want,
|
2021-04-05 16:19:35 +00:00
|
|
|
loff_t endoff, int *got);
|
2019-07-25 12:16:43 +00:00
|
|
|
extern int ceph_try_get_caps(struct inode *inode,
|
2018-10-15 15:45:57 +00:00
|
|
|
int need, int want, bool nonblock, int *got);
|
2009-10-06 18:31:07 +00:00
|
|
|
|
|
|
|
/* for counting open files by mode */
|
2020-03-05 12:21:00 +00:00
|
|
|
extern void ceph_get_fmode(struct ceph_inode_info *ci, int mode, int count);
|
|
|
|
extern void ceph_put_fmode(struct ceph_inode_info *ci, int mode, int count);
|
|
|
|
extern void __ceph_touch_fmode(struct ceph_inode_info *ci,
|
|
|
|
struct ceph_mds_client *mdsc, int fmode);
|
2009-10-06 18:31:07 +00:00
|
|
|
|
|
|
|
/* addr.c */
|
|
|
|
extern const struct address_space_operations ceph_aops;
|
2021-06-29 21:37:05 +00:00
|
|
|
extern const struct netfs_request_ops ceph_netfs_ops;
|
2009-10-06 18:31:07 +00:00
|
|
|
extern int ceph_mmap(struct file *file, struct vm_area_struct *vma);
|
2021-12-15 23:48:33 +00:00
|
|
|
extern int ceph_uninline_data(struct file *file);
|
2019-07-25 12:16:43 +00:00
|
|
|
extern int ceph_pool_perm_check(struct inode *inode, int need);
|
2015-04-27 07:33:28 +00:00
|
|
|
extern void ceph_pool_perm_destroy(struct ceph_mds_client* mdsc);
|
2021-09-02 17:06:57 +00:00
|
|
|
int ceph_purge_inode_cap(struct inode *inode, struct ceph_cap *cap, bool *invalidate);
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2022-06-07 02:13:53 +00:00
|
|
|
static inline bool ceph_has_inline_data(struct ceph_inode_info *ci)
|
|
|
|
{
|
|
|
|
if (ci->i_inline_version == CEPH_INLINE_NONE ||
|
|
|
|
ci->i_inline_version == 1) /* initial version, no data */
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-10-06 18:31:07 +00:00
|
|
|
/* file.c */
|
|
|
|
extern const struct file_operations ceph_file_fops;
|
2013-02-06 19:11:38 +00:00
|
|
|
|
2020-03-05 12:21:00 +00:00
|
|
|
extern int ceph_renew_caps(struct inode *inode, int fmode);
|
2009-10-06 18:31:07 +00:00
|
|
|
extern int ceph_open(struct inode *inode, struct file *file);
|
2012-07-31 18:27:36 +00:00
|
|
|
extern int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
|
2018-06-08 17:32:02 +00:00
|
|
|
struct file *file, unsigned flags, umode_t mode);
|
2022-08-25 13:31:12 +00:00
|
|
|
extern ssize_t __ceph_sync_read(struct inode *inode, loff_t *ki_pos,
|
|
|
|
struct iov_iter *to, int *retry_op,
|
|
|
|
u64 *last_objver);
|
2009-10-06 18:31:07 +00:00
|
|
|
extern int ceph_release(struct inode *inode, struct file *filp);
|
2014-11-14 13:41:55 +00:00
|
|
|
extern void ceph_fill_inline_data(struct inode *inode, struct page *locked_page,
|
|
|
|
char *data, size_t len);
|
2017-02-13 13:44:19 +00:00
|
|
|
|
2009-10-06 18:31:07 +00:00
|
|
|
/* dir.c */
|
|
|
|
extern const struct file_operations ceph_dir_fops;
|
2015-01-14 05:46:04 +00:00
|
|
|
extern const struct file_operations ceph_snapdir_fops;
|
2009-10-06 18:31:07 +00:00
|
|
|
extern const struct inode_operations ceph_dir_iops;
|
2015-01-14 05:46:04 +00:00
|
|
|
extern const struct inode_operations ceph_snapdir_iops;
|
2016-10-29 01:52:50 +00:00
|
|
|
extern const struct dentry_operations ceph_dentry_ops;
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2016-04-29 03:27:30 +00:00
|
|
|
extern loff_t ceph_make_fpos(unsigned high, unsigned off, bool hash_order);
|
2009-10-06 18:31:07 +00:00
|
|
|
extern int ceph_handle_notrace_create(struct inode *dir, struct dentry *dentry);
|
2021-03-01 13:01:54 +00:00
|
|
|
extern struct dentry *ceph_handle_snapdir(struct ceph_mds_request *req,
|
2021-06-02 16:46:07 +00:00
|
|
|
struct dentry *dentry);
|
2009-10-06 18:31:07 +00:00
|
|
|
extern struct dentry *ceph_finish_lookup(struct ceph_mds_request *req,
|
|
|
|
struct dentry *dentry, int err);
|
|
|
|
|
2019-01-31 08:55:51 +00:00
|
|
|
extern void __ceph_dentry_lease_touch(struct ceph_dentry_info *di);
|
|
|
|
extern void __ceph_dentry_dir_lease_touch(struct ceph_dentry_info *di);
|
2010-05-14 16:35:38 +00:00
|
|
|
extern void ceph_invalidate_dentry_lease(struct dentry *dentry);
|
2019-01-31 08:55:51 +00:00
|
|
|
extern int ceph_trim_dentries(struct ceph_mds_client *mdsc);
|
2011-07-26 18:30:55 +00:00
|
|
|
extern unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn);
|
2015-06-16 12:48:56 +00:00
|
|
|
extern void ceph_readdir_cache_release(struct ceph_readdir_cache_control *ctl);
|
2009-10-06 18:31:07 +00:00
|
|
|
|
|
|
|
/* ioctl.c */
|
|
|
|
extern long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
|
|
|
|
|
|
|
|
/* export.c */
|
|
|
|
extern const struct export_operations ceph_export_ops;
|
2019-03-21 10:20:09 +00:00
|
|
|
struct inode *ceph_lookup_inode(struct super_block *sb, u64 ino);
|
2009-10-06 18:31:07 +00:00
|
|
|
|
2010-08-02 22:34:23 +00:00
|
|
|
/* locks.c */
|
2014-03-09 15:16:40 +00:00
|
|
|
extern __init void ceph_flock_init(void);
|
2010-08-02 22:34:23 +00:00
|
|
|
extern int ceph_lock(struct file *file, int cmd, struct file_lock *fl);
|
|
|
|
extern int ceph_flock(struct file *file, int cmd, struct file_lock *fl);
|
|
|
|
extern void ceph_count_locks(struct inode *inode, int *p_num, int *f_num);
|
2013-05-15 18:03:35 +00:00
|
|
|
extern int ceph_encode_locks_to_buffer(struct inode *inode,
|
|
|
|
struct ceph_filelock *flocks,
|
|
|
|
int num_fcntl_locks,
|
|
|
|
int num_flock_locks);
|
|
|
|
extern int ceph_locks_to_pagelist(struct ceph_filelock *flocks,
|
|
|
|
struct ceph_pagelist *pagelist,
|
|
|
|
int num_fcntl_locks, int num_flock_locks);
|
2010-08-02 22:34:23 +00:00
|
|
|
|
2010-04-06 22:14:15 +00:00
|
|
|
/* debugfs.c */
|
2019-06-12 14:55:38 +00:00
|
|
|
extern void ceph_fs_debugfs_init(struct ceph_fs_client *client);
|
2010-04-06 22:14:15 +00:00
|
|
|
extern void ceph_fs_debugfs_cleanup(struct ceph_fs_client *client);
|
|
|
|
|
2018-01-05 10:47:18 +00:00
|
|
|
/* quota.c */
|
2022-04-27 15:57:04 +00:00
|
|
|
|
|
|
|
enum quota_get_realm {
|
|
|
|
QUOTA_GET_MAX_FILES,
|
|
|
|
QUOTA_GET_MAX_BYTES,
|
|
|
|
QUOTA_GET_ANY
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline bool __ceph_has_quota(struct ceph_inode_info *ci,
|
|
|
|
enum quota_get_realm which)
|
2018-01-12 17:19:29 +00:00
|
|
|
{
|
2022-04-27 15:57:04 +00:00
|
|
|
bool has_quota = false;
|
|
|
|
|
|
|
|
switch (which) {
|
|
|
|
case QUOTA_GET_MAX_BYTES:
|
|
|
|
has_quota = !!ci->i_max_bytes;
|
|
|
|
break;
|
|
|
|
case QUOTA_GET_MAX_FILES:
|
|
|
|
has_quota = !!ci->i_max_files;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
has_quota = !!(ci->i_max_files || ci->i_max_bytes);
|
|
|
|
}
|
|
|
|
return has_quota;
|
2018-01-12 17:19:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extern void ceph_adjust_quota_realms_count(struct inode *inode, bool inc);
|
|
|
|
|
|
|
|
static inline void __ceph_update_quota(struct ceph_inode_info *ci,
|
|
|
|
u64 max_bytes, u64 max_files)
|
|
|
|
{
|
|
|
|
bool had_quota, has_quota;
|
2022-04-27 15:57:04 +00:00
|
|
|
had_quota = __ceph_has_quota(ci, QUOTA_GET_ANY);
|
2018-01-12 17:19:29 +00:00
|
|
|
ci->i_max_bytes = max_bytes;
|
|
|
|
ci->i_max_files = max_files;
|
2022-04-27 15:57:04 +00:00
|
|
|
has_quota = __ceph_has_quota(ci, QUOTA_GET_ANY);
|
2018-01-12 17:19:29 +00:00
|
|
|
|
|
|
|
if (had_quota != has_quota)
|
netfs: Fix gcc-12 warning by embedding vfs inode in netfs_i_context
While randstruct was satisfied with using an open-coded "void *" offset
cast for the netfs_i_context <-> inode casting, __builtin_object_size() as
used by FORTIFY_SOURCE was not as easily fooled. This was causing the
following complaint[1] from gcc v12:
In file included from include/linux/string.h:253,
from include/linux/ceph/ceph_debug.h:7,
from fs/ceph/inode.c:2:
In function 'fortify_memset_chk',
inlined from 'netfs_i_context_init' at include/linux/netfs.h:326:2,
inlined from 'ceph_alloc_inode' at fs/ceph/inode.c:463:2:
include/linux/fortify-string.h:242:25: warning: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Wattribute-warning]
242 | __write_overflow_field(p_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix this by embedding a struct inode into struct netfs_i_context (which
should perhaps be renamed to struct netfs_inode). The struct inode
vfs_inode fields are then removed from the 9p, afs, ceph and cifs inode
structs and vfs_inode is then simply changed to "netfs.inode" in those
filesystems.
Further, rename netfs_i_context to netfs_inode, get rid of the
netfs_inode() function that converted a netfs_i_context pointer to an
inode pointer (that can now be done with &ctx->inode) and rename the
netfs_i_context() function to netfs_inode() (which is now a wrapper
around container_of()).
Most of the changes were done with:
perl -p -i -e 's/vfs_inode/netfs.inode/'g \
`git grep -l 'vfs_inode' -- fs/{9p,afs,ceph,cifs}/*.[ch]`
Kees suggested doing it with a pair structure[2] and a special
declarator to insert that into the network filesystem's inode
wrapper[3], but I think it's cleaner to embed it - and then it doesn't
matter if struct randomisation reorders things.
Dave Chinner suggested using a filesystem-specific VFS_I() function in
each filesystem to convert that filesystem's own inode wrapper struct
into the VFS inode struct[4].
Version #2:
- Fix a couple of missed name changes due to a disabled cifs option.
- Rename nfs_i_context to nfs_inode
- Use "netfs" instead of "nic" as the member name in per-fs inode wrapper
structs.
[ This also undoes commit 507160f46c55 ("netfs: gcc-12: temporarily
disable '-Wattribute-warning' for now") that is no longer needed ]
Fixes: bc899ee1c898 ("netfs: Add a netfs inode context")
Reported-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
cc: Jonathan Corbet <corbet@lwn.net>
cc: Eric Van Hensbergen <ericvh@gmail.com>
cc: Latchesar Ionkov <lucho@ionkov.net>
cc: Dominique Martinet <asmadeus@codewreck.org>
cc: Christian Schoenebeck <linux_oss@crudebyte.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: Ilya Dryomov <idryomov@gmail.com>
cc: Steve French <smfrench@gmail.com>
cc: William Kucharski <william.kucharski@oracle.com>
cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
cc: Dave Chinner <david@fromorbit.com>
cc: linux-doc@vger.kernel.org
cc: v9fs-developer@lists.sourceforge.net
cc: linux-afs@lists.infradead.org
cc: ceph-devel@vger.kernel.org
cc: linux-cifs@vger.kernel.org
cc: samba-technical@lists.samba.org
cc: linux-fsdevel@vger.kernel.org
cc: linux-hardening@vger.kernel.org
Link: https://lore.kernel.org/r/d2ad3a3d7bdd794c6efb562d2f2b655fb67756b9.camel@kernel.org/ [1]
Link: https://lore.kernel.org/r/20220517210230.864239-1-keescook@chromium.org/ [2]
Link: https://lore.kernel.org/r/20220518202212.2322058-1-keescook@chromium.org/ [3]
Link: https://lore.kernel.org/r/20220524101205.GI2306852@dread.disaster.area/ [4]
Link: https://lore.kernel.org/r/165296786831.3591209.12111293034669289733.stgit@warthog.procyon.org.uk/ # v1
Link: https://lore.kernel.org/r/165305805651.4094995.7763502506786714216.stgit@warthog.procyon.org.uk # v2
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2022-06-09 20:46:04 +00:00
|
|
|
ceph_adjust_quota_realms_count(&ci->netfs.inode, has_quota);
|
2018-01-12 17:19:29 +00:00
|
|
|
}
|
|
|
|
|
2023-11-07 02:44:41 +00:00
|
|
|
static inline int __ceph_sparse_read_ext_count(struct inode *inode, u64 len)
|
|
|
|
{
|
|
|
|
int cnt = 0;
|
|
|
|
|
|
|
|
if (IS_ENCRYPTED(inode)) {
|
|
|
|
cnt = len >> CEPH_FSCRYPT_BLOCK_SHIFT;
|
|
|
|
if (cnt > CEPH_SPARSE_EXT_ARRAY_INITIAL)
|
|
|
|
cnt = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
|
2018-01-05 10:47:18 +00:00
|
|
|
extern void ceph_handle_quota(struct ceph_mds_client *mdsc,
|
|
|
|
struct ceph_mds_session *session,
|
|
|
|
struct ceph_msg *msg);
|
2018-01-05 10:47:19 +00:00
|
|
|
extern bool ceph_quota_is_max_files_exceeded(struct inode *inode);
|
2020-11-12 15:23:21 +00:00
|
|
|
extern bool ceph_quota_is_same_realm(struct inode *old, struct inode *new);
|
2018-01-05 10:47:21 +00:00
|
|
|
extern bool ceph_quota_is_max_bytes_exceeded(struct inode *inode,
|
|
|
|
loff_t newlen);
|
2018-01-05 10:47:22 +00:00
|
|
|
extern bool ceph_quota_is_max_bytes_approaching(struct inode *inode,
|
|
|
|
loff_t newlen);
|
2018-01-31 10:53:13 +00:00
|
|
|
extern bool ceph_quota_update_statfs(struct ceph_fs_client *fsc,
|
|
|
|
struct kstatfs *buf);
|
2019-03-21 10:20:10 +00:00
|
|
|
extern void ceph_cleanup_quotarealms_inodes(struct ceph_mds_client *mdsc);
|
2018-01-05 10:47:18 +00:00
|
|
|
|
2022-12-21 06:13:51 +00:00
|
|
|
bool ceph_inc_mds_stopping_blocker(struct ceph_mds_client *mdsc,
|
|
|
|
struct ceph_mds_session *session);
|
|
|
|
void ceph_dec_mds_stopping_blocker(struct ceph_mds_client *mdsc);
|
2023-05-09 08:38:49 +00:00
|
|
|
bool ceph_inc_osd_stopping_blocker(struct ceph_mds_client *mdsc);
|
|
|
|
void ceph_dec_osd_stopping_blocker(struct ceph_mds_client *mdsc);
|
2009-10-06 18:31:07 +00:00
|
|
|
#endif /* _FS_CEPH_SUPER_H */
|