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 22:07:57 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2015-07-17 22:38:13 +08:00
|
|
|
/*
|
|
|
|
* (C) 2001 Clemson University and The University of Chicago
|
|
|
|
*
|
|
|
|
* See COPYING in top-level directory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Linux VFS namei operations.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "protocol.h"
|
2015-12-05 01:56:14 +08:00
|
|
|
#include "orangefs-kernel.h"
|
2015-07-17 22:38:13 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get a newly allocated inode to go with a negative dentry.
|
|
|
|
*/
|
2021-01-21 21:19:43 +08:00
|
|
|
static int orangefs_create(struct user_namespace *mnt_userns,
|
|
|
|
struct inode *dir,
|
2015-07-17 22:38:13 +08:00
|
|
|
struct dentry *dentry,
|
|
|
|
umode_t mode,
|
|
|
|
bool exclusive)
|
|
|
|
{
|
2015-11-25 04:12:14 +08:00
|
|
|
struct orangefs_inode_s *parent = ORANGEFS_I(dir);
|
|
|
|
struct orangefs_kernel_op_s *new_op;
|
2017-11-11 01:08:01 +08:00
|
|
|
struct orangefs_object_kref ref;
|
2015-07-17 22:38:13 +08:00
|
|
|
struct inode *inode;
|
2017-11-08 04:01:40 +08:00
|
|
|
struct iattr iattr;
|
2015-07-17 22:38:13 +08:00
|
|
|
int ret;
|
|
|
|
|
2016-08-08 00:20:01 +08:00
|
|
|
gossip_debug(GOSSIP_NAME_DEBUG, "%s: %pd\n",
|
2016-02-17 06:09:09 +08:00
|
|
|
__func__,
|
2016-08-08 00:20:01 +08:00
|
|
|
dentry);
|
2015-07-17 22:38:13 +08:00
|
|
|
|
2015-11-25 04:12:14 +08:00
|
|
|
new_op = op_alloc(ORANGEFS_VFS_OP_CREATE);
|
2015-07-17 22:38:13 +08:00
|
|
|
if (!new_op)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
new_op->upcall.req.create.parent_refn = parent->refn;
|
|
|
|
|
|
|
|
fill_default_sys_attrs(new_op->upcall.req.create.attributes,
|
2015-11-25 04:12:14 +08:00
|
|
|
ORANGEFS_TYPE_METAFILE, mode);
|
2015-07-17 22:38:13 +08:00
|
|
|
|
|
|
|
strncpy(new_op->upcall.req.create.d_name,
|
2018-01-08 20:22:33 +08:00
|
|
|
dentry->d_name.name, ORANGEFS_NAME_MAX - 1);
|
2015-07-17 22:38:13 +08:00
|
|
|
|
|
|
|
ret = service_operation(new_op, __func__, get_interruptible_flag(dir));
|
|
|
|
|
|
|
|
gossip_debug(GOSSIP_NAME_DEBUG,
|
2016-08-08 00:20:01 +08:00
|
|
|
"%s: %pd: handle:%pU: fsid:%d: new_op:%p: ret:%d:\n",
|
2016-02-17 06:09:09 +08:00
|
|
|
__func__,
|
2016-08-08 00:20:01 +08:00
|
|
|
dentry,
|
2015-07-17 22:38:13 +08:00
|
|
|
&new_op->downcall.resp.create.refn.khandle,
|
2016-02-17 06:09:09 +08:00
|
|
|
new_op->downcall.resp.create.refn.fs_id,
|
|
|
|
new_op,
|
|
|
|
ret);
|
2015-07-17 22:38:13 +08:00
|
|
|
|
2016-02-17 06:09:09 +08:00
|
|
|
if (ret < 0)
|
2015-07-17 22:38:13 +08:00
|
|
|
goto out;
|
|
|
|
|
2017-11-11 01:08:01 +08:00
|
|
|
ref = new_op->downcall.resp.create.refn;
|
|
|
|
|
|
|
|
inode = orangefs_new_inode(dir->i_sb, dir, S_IFREG | mode, 0, &ref);
|
2015-07-17 22:38:13 +08:00
|
|
|
if (IS_ERR(inode)) {
|
2016-08-08 00:20:01 +08:00
|
|
|
gossip_err("%s: Failed to allocate inode for file :%pd:\n",
|
2016-02-17 06:09:09 +08:00
|
|
|
__func__,
|
2016-08-08 00:20:01 +08:00
|
|
|
dentry);
|
2015-07-17 22:38:13 +08:00
|
|
|
ret = PTR_ERR(inode);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
gossip_debug(GOSSIP_NAME_DEBUG,
|
2016-08-08 00:20:01 +08:00
|
|
|
"%s: Assigned inode :%pU: for file :%pd:\n",
|
2016-02-17 06:09:09 +08:00
|
|
|
__func__,
|
|
|
|
get_khandle_from_ino(inode),
|
2016-08-08 00:20:01 +08:00
|
|
|
dentry);
|
2015-07-17 22:38:13 +08:00
|
|
|
|
2018-05-04 20:23:01 +08:00
|
|
|
d_instantiate_new(dentry, inode);
|
2016-10-17 16:14:23 +08:00
|
|
|
orangefs_set_timeout(dentry);
|
2015-07-17 22:38:13 +08:00
|
|
|
|
|
|
|
gossip_debug(GOSSIP_NAME_DEBUG,
|
2016-08-08 00:20:01 +08:00
|
|
|
"%s: dentry instantiated for %pd\n",
|
2016-02-17 06:09:09 +08:00
|
|
|
__func__,
|
2016-08-08 00:20:01 +08:00
|
|
|
dentry);
|
2015-07-17 22:38:13 +08:00
|
|
|
|
2017-11-08 04:01:40 +08:00
|
|
|
memset(&iattr, 0, sizeof iattr);
|
2018-02-14 04:13:46 +08:00
|
|
|
iattr.ia_valid |= ATTR_MTIME | ATTR_CTIME;
|
|
|
|
iattr.ia_mtime = iattr.ia_ctime = current_time(dir);
|
|
|
|
__orangefs_setattr(dir, &iattr);
|
2015-07-17 22:38:13 +08:00
|
|
|
ret = 0;
|
|
|
|
out:
|
2018-10-19 01:58:25 +08:00
|
|
|
op_release(new_op);
|
2016-02-17 06:09:09 +08:00
|
|
|
gossip_debug(GOSSIP_NAME_DEBUG,
|
2016-08-08 00:20:01 +08:00
|
|
|
"%s: %pd: returning %d\n",
|
2016-02-17 06:09:09 +08:00
|
|
|
__func__,
|
2016-08-08 00:20:01 +08:00
|
|
|
dentry,
|
2016-02-17 06:09:09 +08:00
|
|
|
ret);
|
2015-07-17 22:38:13 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Attempt to resolve an object name (dentry->d_name), parent handle, and
|
|
|
|
* fsid into a handle for the object.
|
|
|
|
*/
|
2015-11-25 04:12:14 +08:00
|
|
|
static struct dentry *orangefs_lookup(struct inode *dir, struct dentry *dentry,
|
2015-07-17 22:38:13 +08:00
|
|
|
unsigned int flags)
|
|
|
|
{
|
2015-11-25 04:12:14 +08:00
|
|
|
struct orangefs_inode_s *parent = ORANGEFS_I(dir);
|
|
|
|
struct orangefs_kernel_op_s *new_op;
|
2015-07-17 22:38:13 +08:00
|
|
|
struct inode *inode;
|
|
|
|
int ret = -EINVAL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* in theory we could skip a lookup here (if the intent is to
|
|
|
|
* create) in order to avoid a potentially failed lookup, but
|
|
|
|
* leaving it in can skip a valid lookup and try to create a file
|
|
|
|
* that already exists (e.g. the vfs already handles checking for
|
|
|
|
* -EEXIST on O_EXCL opens, which is broken if we skip this lookup
|
|
|
|
* in the create path)
|
|
|
|
*/
|
2016-08-08 00:20:01 +08:00
|
|
|
gossip_debug(GOSSIP_NAME_DEBUG, "%s called on %pd\n",
|
|
|
|
__func__, dentry);
|
2015-07-17 22:38:13 +08:00
|
|
|
|
2016-02-21 03:22:40 +08:00
|
|
|
if (dentry->d_name.len > (ORANGEFS_NAME_MAX - 1))
|
2015-07-17 22:38:13 +08:00
|
|
|
return ERR_PTR(-ENAMETOOLONG);
|
|
|
|
|
2015-11-25 04:12:14 +08:00
|
|
|
new_op = op_alloc(ORANGEFS_VFS_OP_LOOKUP);
|
2015-07-17 22:38:13 +08:00
|
|
|
if (!new_op)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
|
2015-12-11 23:46:22 +08:00
|
|
|
new_op->upcall.req.lookup.sym_follow = ORANGEFS_LOOKUP_LINK_NO_FOLLOW;
|
2015-07-17 22:38:13 +08:00
|
|
|
|
|
|
|
gossip_debug(GOSSIP_NAME_DEBUG, "%s:%s:%d using parent %pU\n",
|
|
|
|
__FILE__,
|
|
|
|
__func__,
|
|
|
|
__LINE__,
|
|
|
|
&parent->refn.khandle);
|
|
|
|
new_op->upcall.req.lookup.parent_refn = parent->refn;
|
|
|
|
|
|
|
|
strncpy(new_op->upcall.req.lookup.d_name, dentry->d_name.name,
|
2018-01-08 20:22:33 +08:00
|
|
|
ORANGEFS_NAME_MAX - 1);
|
2015-07-17 22:38:13 +08:00
|
|
|
|
|
|
|
gossip_debug(GOSSIP_NAME_DEBUG,
|
2016-02-21 03:47:13 +08:00
|
|
|
"%s: doing lookup on %s under %pU,%d\n",
|
2015-07-17 22:38:13 +08:00
|
|
|
__func__,
|
|
|
|
new_op->upcall.req.lookup.d_name,
|
|
|
|
&new_op->upcall.req.lookup.parent_refn.khandle,
|
2016-02-21 03:47:13 +08:00
|
|
|
new_op->upcall.req.lookup.parent_refn.fs_id);
|
2015-07-17 22:38:13 +08:00
|
|
|
|
|
|
|
ret = service_operation(new_op, __func__, get_interruptible_flag(dir));
|
|
|
|
|
|
|
|
gossip_debug(GOSSIP_NAME_DEBUG,
|
|
|
|
"Lookup Got %pU, fsid %d (ret=%d)\n",
|
|
|
|
&new_op->downcall.resp.lookup.refn.khandle,
|
|
|
|
new_op->downcall.resp.lookup.refn.fs_id,
|
|
|
|
ret);
|
|
|
|
|
2018-10-19 02:05:46 +08:00
|
|
|
if (ret == 0) {
|
2018-05-01 11:12:03 +08:00
|
|
|
orangefs_set_timeout(dentry);
|
|
|
|
inode = orangefs_iget(dir->i_sb, &new_op->downcall.resp.lookup.refn);
|
|
|
|
} else if (ret == -ENOENT) {
|
|
|
|
inode = NULL;
|
|
|
|
} else {
|
2015-07-17 22:38:13 +08:00
|
|
|
/* must be a non-recoverable error */
|
2018-05-01 11:12:03 +08:00
|
|
|
inode = ERR_PTR(ret);
|
2015-07-17 22:38:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
op_release(new_op);
|
2018-05-01 11:12:03 +08:00
|
|
|
return d_splice_alias(inode, dentry);
|
2015-07-17 22:38:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* return 0 on success; non-zero otherwise */
|
2015-11-25 04:12:14 +08:00
|
|
|
static int orangefs_unlink(struct inode *dir, struct dentry *dentry)
|
2015-07-17 22:38:13 +08:00
|
|
|
{
|
|
|
|
struct inode *inode = dentry->d_inode;
|
2015-11-25 04:12:14 +08:00
|
|
|
struct orangefs_inode_s *parent = ORANGEFS_I(dir);
|
|
|
|
struct orangefs_kernel_op_s *new_op;
|
2017-11-08 04:01:40 +08:00
|
|
|
struct iattr iattr;
|
2015-07-17 22:38:13 +08:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
gossip_debug(GOSSIP_NAME_DEBUG,
|
2016-08-08 00:20:01 +08:00
|
|
|
"%s: called on %pd\n"
|
2015-07-17 22:38:13 +08:00
|
|
|
" (inode %pU): Parent is %pU | fs_id %d\n",
|
|
|
|
__func__,
|
2016-08-08 00:20:01 +08:00
|
|
|
dentry,
|
2015-07-17 22:38:13 +08:00
|
|
|
get_khandle_from_ino(inode),
|
|
|
|
&parent->refn.khandle,
|
|
|
|
parent->refn.fs_id);
|
|
|
|
|
2015-11-25 04:12:14 +08:00
|
|
|
new_op = op_alloc(ORANGEFS_VFS_OP_REMOVE);
|
2015-07-17 22:38:13 +08:00
|
|
|
if (!new_op)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
new_op->upcall.req.remove.parent_refn = parent->refn;
|
|
|
|
strncpy(new_op->upcall.req.remove.d_name, dentry->d_name.name,
|
2018-01-08 20:22:33 +08:00
|
|
|
ORANGEFS_NAME_MAX - 1);
|
2015-07-17 22:38:13 +08:00
|
|
|
|
2015-11-25 04:12:14 +08:00
|
|
|
ret = service_operation(new_op, "orangefs_unlink",
|
2015-07-17 22:38:13 +08:00
|
|
|
get_interruptible_flag(inode));
|
|
|
|
|
2016-02-17 06:09:09 +08:00
|
|
|
gossip_debug(GOSSIP_NAME_DEBUG,
|
|
|
|
"%s: service_operation returned:%d:\n",
|
|
|
|
__func__,
|
|
|
|
ret);
|
|
|
|
|
2015-07-17 22:38:13 +08:00
|
|
|
op_release(new_op);
|
|
|
|
|
|
|
|
if (!ret) {
|
|
|
|
drop_nlink(inode);
|
|
|
|
|
2017-11-08 04:01:40 +08:00
|
|
|
memset(&iattr, 0, sizeof iattr);
|
2018-02-14 04:13:46 +08:00
|
|
|
iattr.ia_valid |= ATTR_MTIME | ATTR_CTIME;
|
|
|
|
iattr.ia_mtime = iattr.ia_ctime = current_time(dir);
|
|
|
|
__orangefs_setattr(dir, &iattr);
|
2015-07-17 22:38:13 +08:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-01-21 21:19:43 +08:00
|
|
|
static int orangefs_symlink(struct user_namespace *mnt_userns,
|
|
|
|
struct inode *dir,
|
2015-07-17 22:38:13 +08:00
|
|
|
struct dentry *dentry,
|
|
|
|
const char *symname)
|
|
|
|
{
|
2015-11-25 04:12:14 +08:00
|
|
|
struct orangefs_inode_s *parent = ORANGEFS_I(dir);
|
|
|
|
struct orangefs_kernel_op_s *new_op;
|
2017-11-11 01:08:01 +08:00
|
|
|
struct orangefs_object_kref ref;
|
2015-07-17 22:38:13 +08:00
|
|
|
struct inode *inode;
|
2017-11-08 04:01:40 +08:00
|
|
|
struct iattr iattr;
|
2019-08-13 18:53:37 +08:00
|
|
|
int mode = 0755;
|
2015-07-17 22:38:13 +08:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
gossip_debug(GOSSIP_NAME_DEBUG, "%s: called\n", __func__);
|
|
|
|
|
|
|
|
if (!symname)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2016-03-01 05:07:35 +08:00
|
|
|
if (strlen(symname)+1 > ORANGEFS_NAME_MAX)
|
|
|
|
return -ENAMETOOLONG;
|
|
|
|
|
2015-11-25 04:12:14 +08:00
|
|
|
new_op = op_alloc(ORANGEFS_VFS_OP_SYMLINK);
|
2015-07-17 22:38:13 +08:00
|
|
|
if (!new_op)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
new_op->upcall.req.sym.parent_refn = parent->refn;
|
|
|
|
|
|
|
|
fill_default_sys_attrs(new_op->upcall.req.sym.attributes,
|
2015-11-25 04:12:14 +08:00
|
|
|
ORANGEFS_TYPE_SYMLINK,
|
2015-07-17 22:38:13 +08:00
|
|
|
mode);
|
|
|
|
|
|
|
|
strncpy(new_op->upcall.req.sym.entry_name,
|
|
|
|
dentry->d_name.name,
|
2018-01-08 20:22:33 +08:00
|
|
|
ORANGEFS_NAME_MAX - 1);
|
|
|
|
strncpy(new_op->upcall.req.sym.target, symname, ORANGEFS_NAME_MAX - 1);
|
2015-07-17 22:38:13 +08:00
|
|
|
|
|
|
|
ret = service_operation(new_op, __func__, get_interruptible_flag(dir));
|
|
|
|
|
|
|
|
gossip_debug(GOSSIP_NAME_DEBUG,
|
2015-11-25 04:12:14 +08:00
|
|
|
"Symlink Got ORANGEFS handle %pU on fsid %d (ret=%d)\n",
|
2015-07-17 22:38:13 +08:00
|
|
|
&new_op->downcall.resp.sym.refn.khandle,
|
|
|
|
new_op->downcall.resp.sym.refn.fs_id, ret);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
gossip_debug(GOSSIP_NAME_DEBUG,
|
|
|
|
"%s: failed with error code %d\n",
|
|
|
|
__func__, ret);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2017-11-11 01:08:01 +08:00
|
|
|
ref = new_op->downcall.resp.sym.refn;
|
|
|
|
|
|
|
|
inode = orangefs_new_inode(dir->i_sb, dir, S_IFLNK | mode, 0, &ref);
|
2015-07-17 22:38:13 +08:00
|
|
|
if (IS_ERR(inode)) {
|
|
|
|
gossip_err
|
2015-11-25 04:12:14 +08:00
|
|
|
("*** Failed to allocate orangefs symlink inode\n");
|
2015-07-17 22:38:13 +08:00
|
|
|
ret = PTR_ERR(inode);
|
|
|
|
goto out;
|
|
|
|
}
|
2018-06-01 00:36:58 +08:00
|
|
|
/*
|
|
|
|
* This is necessary because orangefs_inode_getattr will not
|
|
|
|
* re-read symlink size as it is impossible for it to change.
|
|
|
|
* Invalidating the cache does not help. orangefs_new_inode
|
|
|
|
* does not set the correct size (it does not know symname).
|
|
|
|
*/
|
|
|
|
inode->i_size = strlen(symname);
|
2015-07-17 22:38:13 +08:00
|
|
|
|
|
|
|
gossip_debug(GOSSIP_NAME_DEBUG,
|
|
|
|
"Assigned symlink inode new number of %pU\n",
|
|
|
|
get_khandle_from_ino(inode));
|
|
|
|
|
2018-05-04 20:23:01 +08:00
|
|
|
d_instantiate_new(dentry, inode);
|
2016-10-17 16:14:23 +08:00
|
|
|
orangefs_set_timeout(dentry);
|
2015-07-17 22:38:13 +08:00
|
|
|
|
|
|
|
gossip_debug(GOSSIP_NAME_DEBUG,
|
2016-08-08 00:20:01 +08:00
|
|
|
"Inode (Symlink) %pU -> %pd\n",
|
2015-07-17 22:38:13 +08:00
|
|
|
get_khandle_from_ino(inode),
|
2016-08-08 00:20:01 +08:00
|
|
|
dentry);
|
2015-07-17 22:38:13 +08:00
|
|
|
|
2017-11-08 04:01:40 +08:00
|
|
|
memset(&iattr, 0, sizeof iattr);
|
2018-02-14 04:13:46 +08:00
|
|
|
iattr.ia_valid |= ATTR_MTIME | ATTR_CTIME;
|
|
|
|
iattr.ia_mtime = iattr.ia_ctime = current_time(dir);
|
|
|
|
__orangefs_setattr(dir, &iattr);
|
2015-07-17 22:38:13 +08:00
|
|
|
ret = 0;
|
|
|
|
out:
|
2018-10-19 01:58:25 +08:00
|
|
|
op_release(new_op);
|
2015-07-17 22:38:13 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-01-21 21:19:43 +08:00
|
|
|
static int orangefs_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
|
|
|
|
struct dentry *dentry, umode_t mode)
|
2015-07-17 22:38:13 +08:00
|
|
|
{
|
2015-11-25 04:12:14 +08:00
|
|
|
struct orangefs_inode_s *parent = ORANGEFS_I(dir);
|
|
|
|
struct orangefs_kernel_op_s *new_op;
|
2017-11-11 01:08:01 +08:00
|
|
|
struct orangefs_object_kref ref;
|
2015-07-17 22:38:13 +08:00
|
|
|
struct inode *inode;
|
2017-11-08 04:01:40 +08:00
|
|
|
struct iattr iattr;
|
2015-07-17 22:38:13 +08:00
|
|
|
int ret;
|
|
|
|
|
2015-11-25 04:12:14 +08:00
|
|
|
new_op = op_alloc(ORANGEFS_VFS_OP_MKDIR);
|
2015-07-17 22:38:13 +08:00
|
|
|
if (!new_op)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
new_op->upcall.req.mkdir.parent_refn = parent->refn;
|
|
|
|
|
|
|
|
fill_default_sys_attrs(new_op->upcall.req.mkdir.attributes,
|
2015-11-25 04:12:14 +08:00
|
|
|
ORANGEFS_TYPE_DIRECTORY, mode);
|
2015-07-17 22:38:13 +08:00
|
|
|
|
|
|
|
strncpy(new_op->upcall.req.mkdir.d_name,
|
2018-01-08 20:22:33 +08:00
|
|
|
dentry->d_name.name, ORANGEFS_NAME_MAX - 1);
|
2015-07-17 22:38:13 +08:00
|
|
|
|
|
|
|
ret = service_operation(new_op, __func__, get_interruptible_flag(dir));
|
|
|
|
|
|
|
|
gossip_debug(GOSSIP_NAME_DEBUG,
|
2015-11-25 04:12:14 +08:00
|
|
|
"Mkdir Got ORANGEFS handle %pU on fsid %d\n",
|
2015-07-17 22:38:13 +08:00
|
|
|
&new_op->downcall.resp.mkdir.refn.khandle,
|
|
|
|
new_op->downcall.resp.mkdir.refn.fs_id);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
gossip_debug(GOSSIP_NAME_DEBUG,
|
|
|
|
"%s: failed with error code %d\n",
|
|
|
|
__func__, ret);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2017-11-11 01:08:01 +08:00
|
|
|
ref = new_op->downcall.resp.mkdir.refn;
|
|
|
|
|
|
|
|
inode = orangefs_new_inode(dir->i_sb, dir, S_IFDIR | mode, 0, &ref);
|
2015-07-17 22:38:13 +08:00
|
|
|
if (IS_ERR(inode)) {
|
2015-11-25 04:12:14 +08:00
|
|
|
gossip_err("*** Failed to allocate orangefs dir inode\n");
|
2015-07-17 22:38:13 +08:00
|
|
|
ret = PTR_ERR(inode);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
gossip_debug(GOSSIP_NAME_DEBUG,
|
|
|
|
"Assigned dir inode new number of %pU\n",
|
|
|
|
get_khandle_from_ino(inode));
|
|
|
|
|
2018-05-04 20:23:01 +08:00
|
|
|
d_instantiate_new(dentry, inode);
|
2016-10-17 16:14:23 +08:00
|
|
|
orangefs_set_timeout(dentry);
|
2015-07-17 22:38:13 +08:00
|
|
|
|
|
|
|
gossip_debug(GOSSIP_NAME_DEBUG,
|
2016-08-08 00:20:01 +08:00
|
|
|
"Inode (Directory) %pU -> %pd\n",
|
2015-07-17 22:38:13 +08:00
|
|
|
get_khandle_from_ino(inode),
|
2016-08-08 00:20:01 +08:00
|
|
|
dentry);
|
2015-07-17 22:38:13 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTE: we have no good way to keep nlink consistent for directories
|
|
|
|
* across clients; keep constant at 1.
|
|
|
|
*/
|
2017-11-08 04:01:40 +08:00
|
|
|
memset(&iattr, 0, sizeof iattr);
|
2018-02-14 04:13:46 +08:00
|
|
|
iattr.ia_valid |= ATTR_MTIME | ATTR_CTIME;
|
|
|
|
iattr.ia_mtime = iattr.ia_ctime = current_time(dir);
|
|
|
|
__orangefs_setattr(dir, &iattr);
|
2015-07-17 22:38:13 +08:00
|
|
|
out:
|
2018-10-19 01:58:25 +08:00
|
|
|
op_release(new_op);
|
2015-07-17 22:38:13 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-01-21 21:19:43 +08:00
|
|
|
static int orangefs_rename(struct user_namespace *mnt_userns,
|
|
|
|
struct inode *old_dir,
|
2015-07-17 22:38:13 +08:00
|
|
|
struct dentry *old_dentry,
|
|
|
|
struct inode *new_dir,
|
fs: make remaining filesystems use .rename2
This is trivial to do:
- add flags argument to foo_rename()
- check if flags is zero
- assign foo_rename() to .rename2 instead of .rename
This doesn't mean it's impossible to support RENAME_NOREPLACE for these
filesystems, but it is not trivial, like for local filesystems.
RENAME_NOREPLACE must guarantee atomicity (i.e. it shouldn't be possible
for a file to be created on one host while it is overwritten by rename on
another host).
Filesystems converted:
9p, afs, ceph, coda, ecryptfs, kernfs, lustre, ncpfs, nfs, ocfs2, orangefs.
After this, we can get rid of the duplicate interfaces for rename.
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: David Howells <dhowells@redhat.com> [AFS]
Acked-by: Mike Marshall <hubcap@omnibond.com>
Cc: Eric Van Hensbergen <ericvh@gmail.com>
Cc: Ilya Dryomov <idryomov@gmail.com>
Cc: Jan Harkes <jaharkes@cs.cmu.edu>
Cc: Tyler Hicks <tyhicks@canonical.com>
Cc: Oleg Drokin <oleg.drokin@intel.com>
Cc: Trond Myklebust <trond.myklebust@primarydata.com>
Cc: Mark Fasheh <mfasheh@suse.com>
2016-09-27 17:03:58 +08:00
|
|
|
struct dentry *new_dentry,
|
|
|
|
unsigned int flags)
|
2015-07-17 22:38:13 +08:00
|
|
|
{
|
2015-11-25 04:12:14 +08:00
|
|
|
struct orangefs_kernel_op_s *new_op;
|
2018-02-12 23:49:24 +08:00
|
|
|
struct iattr iattr;
|
2015-07-17 22:38:13 +08:00
|
|
|
int ret;
|
|
|
|
|
fs: make remaining filesystems use .rename2
This is trivial to do:
- add flags argument to foo_rename()
- check if flags is zero
- assign foo_rename() to .rename2 instead of .rename
This doesn't mean it's impossible to support RENAME_NOREPLACE for these
filesystems, but it is not trivial, like for local filesystems.
RENAME_NOREPLACE must guarantee atomicity (i.e. it shouldn't be possible
for a file to be created on one host while it is overwritten by rename on
another host).
Filesystems converted:
9p, afs, ceph, coda, ecryptfs, kernfs, lustre, ncpfs, nfs, ocfs2, orangefs.
After this, we can get rid of the duplicate interfaces for rename.
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: David Howells <dhowells@redhat.com> [AFS]
Acked-by: Mike Marshall <hubcap@omnibond.com>
Cc: Eric Van Hensbergen <ericvh@gmail.com>
Cc: Ilya Dryomov <idryomov@gmail.com>
Cc: Jan Harkes <jaharkes@cs.cmu.edu>
Cc: Tyler Hicks <tyhicks@canonical.com>
Cc: Oleg Drokin <oleg.drokin@intel.com>
Cc: Trond Myklebust <trond.myklebust@primarydata.com>
Cc: Mark Fasheh <mfasheh@suse.com>
2016-09-27 17:03:58 +08:00
|
|
|
if (flags)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2015-07-17 22:38:13 +08:00
|
|
|
gossip_debug(GOSSIP_NAME_DEBUG,
|
2016-05-30 03:00:34 +08:00
|
|
|
"orangefs_rename: called (%pd2 => %pd2) ct=%d\n",
|
|
|
|
old_dentry, new_dentry, d_count(new_dentry));
|
2015-07-17 22:38:13 +08:00
|
|
|
|
2018-02-12 23:49:24 +08:00
|
|
|
memset(&iattr, 0, sizeof iattr);
|
2018-02-14 04:13:46 +08:00
|
|
|
iattr.ia_valid |= ATTR_MTIME | ATTR_CTIME;
|
|
|
|
iattr.ia_mtime = iattr.ia_ctime = current_time(new_dir);
|
|
|
|
__orangefs_setattr(new_dir, &iattr);
|
2016-06-10 04:32:38 +08:00
|
|
|
|
2015-11-25 04:12:14 +08:00
|
|
|
new_op = op_alloc(ORANGEFS_VFS_OP_RENAME);
|
2015-07-17 22:38:13 +08:00
|
|
|
if (!new_op)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2015-11-25 04:12:14 +08:00
|
|
|
new_op->upcall.req.rename.old_parent_refn = ORANGEFS_I(old_dir)->refn;
|
|
|
|
new_op->upcall.req.rename.new_parent_refn = ORANGEFS_I(new_dir)->refn;
|
2015-07-17 22:38:13 +08:00
|
|
|
|
|
|
|
strncpy(new_op->upcall.req.rename.d_old_name,
|
|
|
|
old_dentry->d_name.name,
|
2018-01-08 20:22:33 +08:00
|
|
|
ORANGEFS_NAME_MAX - 1);
|
2015-07-17 22:38:13 +08:00
|
|
|
strncpy(new_op->upcall.req.rename.d_new_name,
|
|
|
|
new_dentry->d_name.name,
|
2018-01-08 20:22:33 +08:00
|
|
|
ORANGEFS_NAME_MAX - 1);
|
2015-07-17 22:38:13 +08:00
|
|
|
|
|
|
|
ret = service_operation(new_op,
|
2015-11-25 04:12:14 +08:00
|
|
|
"orangefs_rename",
|
2015-07-17 22:38:13 +08:00
|
|
|
get_interruptible_flag(old_dentry->d_inode));
|
|
|
|
|
|
|
|
gossip_debug(GOSSIP_NAME_DEBUG,
|
2015-11-25 04:12:14 +08:00
|
|
|
"orangefs_rename: got downcall status %d\n",
|
2015-07-17 22:38:13 +08:00
|
|
|
ret);
|
|
|
|
|
|
|
|
if (new_dentry->d_inode)
|
2016-09-14 22:48:06 +08:00
|
|
|
new_dentry->d_inode->i_ctime = current_time(new_dentry->d_inode);
|
2015-07-17 22:38:13 +08:00
|
|
|
|
|
|
|
op_release(new_op);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-11-25 04:12:14 +08:00
|
|
|
/* ORANGEFS implementation of VFS inode operations for directories */
|
2016-05-15 06:46:32 +08:00
|
|
|
const struct inode_operations orangefs_dir_inode_operations = {
|
2015-11-25 04:12:14 +08:00
|
|
|
.lookup = orangefs_lookup,
|
|
|
|
.get_acl = orangefs_get_acl,
|
|
|
|
.set_acl = orangefs_set_acl,
|
|
|
|
.create = orangefs_create,
|
|
|
|
.unlink = orangefs_unlink,
|
|
|
|
.symlink = orangefs_symlink,
|
|
|
|
.mkdir = orangefs_mkdir,
|
|
|
|
.rmdir = orangefs_unlink,
|
|
|
|
.rename = orangefs_rename,
|
|
|
|
.setattr = orangefs_setattr,
|
|
|
|
.getattr = orangefs_getattr,
|
|
|
|
.listxattr = orangefs_listxattr,
|
2016-01-31 02:46:54 +08:00
|
|
|
.permission = orangefs_permission,
|
2017-11-08 04:01:40 +08:00
|
|
|
.update_time = orangefs_update_time,
|
2015-07-17 22:38:13 +08:00
|
|
|
};
|