License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 14:07:57 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2015-07-17 14:38:15 +00:00
|
|
|
/*
|
|
|
|
* (C) 2001 Clemson University and The University of Chicago
|
|
|
|
*
|
|
|
|
* See COPYING in top-level directory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "protocol.h"
|
2015-12-04 17:56:14 +00:00
|
|
|
#include "orangefs-kernel.h"
|
|
|
|
#include "orangefs-bufmap.h"
|
2015-07-17 14:38:15 +00:00
|
|
|
|
|
|
|
#include <linux/parser.h>
|
2017-12-12 18:46:30 +00:00
|
|
|
#include <linux/hashtable.h>
|
2021-09-20 12:33:13 +00:00
|
|
|
#include <linux/seq_file.h>
|
2015-07-17 14:38:15 +00:00
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
/* a cache for orangefs-inode objects (i.e. orangefs inode private data) */
|
|
|
|
static struct kmem_cache *orangefs_inode_cache;
|
2015-07-17 14:38:15 +00:00
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
/* list for storing orangefs specific superblocks in use */
|
|
|
|
LIST_HEAD(orangefs_superblocks);
|
2015-07-17 14:38:15 +00:00
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
DEFINE_SPINLOCK(orangefs_superblocks_lock);
|
2015-07-17 14:38:15 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
Opt_intr,
|
|
|
|
Opt_acl,
|
|
|
|
Opt_local_lock,
|
|
|
|
|
|
|
|
Opt_err
|
|
|
|
};
|
|
|
|
|
|
|
|
static const match_table_t tokens = {
|
|
|
|
{ Opt_acl, "acl" },
|
|
|
|
{ Opt_intr, "intr" },
|
|
|
|
{ Opt_local_lock, "local_lock" },
|
|
|
|
{ Opt_err, NULL }
|
|
|
|
};
|
|
|
|
|
2016-08-12 16:02:31 +00:00
|
|
|
uint64_t orangefs_features;
|
2015-07-17 14:38:15 +00:00
|
|
|
|
2017-07-05 15:25:45 +00:00
|
|
|
static int orangefs_show_options(struct seq_file *m, struct dentry *root)
|
|
|
|
{
|
|
|
|
struct orangefs_sb_info_s *orangefs_sb = ORANGEFS_SB(root->d_sb);
|
|
|
|
|
2017-11-27 21:05:09 +00:00
|
|
|
if (root->d_sb->s_flags & SB_POSIXACL)
|
2017-07-05 15:25:45 +00:00
|
|
|
seq_puts(m, ",acl");
|
|
|
|
if (orangefs_sb->flags & ORANGEFS_OPT_INTR)
|
|
|
|
seq_puts(m, ",intr");
|
|
|
|
if (orangefs_sb->flags & ORANGEFS_OPT_LOCAL_LOCK)
|
|
|
|
seq_puts(m, ",local_lock");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-07-17 14:38:15 +00:00
|
|
|
static int parse_mount_options(struct super_block *sb, char *options,
|
|
|
|
int silent)
|
|
|
|
{
|
2015-11-24 20:12:14 +00:00
|
|
|
struct orangefs_sb_info_s *orangefs_sb = ORANGEFS_SB(sb);
|
2015-07-17 14:38:15 +00:00
|
|
|
substring_t args[MAX_OPT_ARGS];
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Force any potential flags that might be set from the mount
|
|
|
|
* to zero, ie, initialize to unset.
|
|
|
|
*/
|
2017-11-27 21:05:09 +00:00
|
|
|
sb->s_flags &= ~SB_POSIXACL;
|
2015-11-24 20:12:14 +00:00
|
|
|
orangefs_sb->flags &= ~ORANGEFS_OPT_INTR;
|
|
|
|
orangefs_sb->flags &= ~ORANGEFS_OPT_LOCAL_LOCK;
|
2015-07-17 14:38:15 +00:00
|
|
|
|
|
|
|
while ((p = strsep(&options, ",")) != NULL) {
|
|
|
|
int token;
|
|
|
|
|
|
|
|
if (!*p)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
token = match_token(p, tokens, args);
|
|
|
|
switch (token) {
|
|
|
|
case Opt_acl:
|
2017-11-27 21:05:09 +00:00
|
|
|
sb->s_flags |= SB_POSIXACL;
|
2015-07-17 14:38:15 +00:00
|
|
|
break;
|
|
|
|
case Opt_intr:
|
2015-11-24 20:12:14 +00:00
|
|
|
orangefs_sb->flags |= ORANGEFS_OPT_INTR;
|
2015-07-17 14:38:15 +00:00
|
|
|
break;
|
|
|
|
case Opt_local_lock:
|
2015-11-24 20:12:14 +00:00
|
|
|
orangefs_sb->flags |= ORANGEFS_OPT_LOCAL_LOCK;
|
2015-07-17 14:38:15 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
fail:
|
|
|
|
if (!silent)
|
|
|
|
gossip_err("Error: mount option [%s] is not supported.\n", p);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
static void orangefs_inode_cache_ctor(void *req)
|
2015-07-17 14:38:15 +00:00
|
|
|
{
|
2015-11-24 20:12:14 +00:00
|
|
|
struct orangefs_inode_s *orangefs_inode = req;
|
2015-07-17 14:38:15 +00:00
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
inode_init_once(&orangefs_inode->vfs_inode);
|
|
|
|
init_rwsem(&orangefs_inode->xattr_sem);
|
2015-07-17 14:38:15 +00:00
|
|
|
}
|
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
static struct inode *orangefs_alloc_inode(struct super_block *sb)
|
2015-07-17 14:38:15 +00:00
|
|
|
{
|
2015-11-24 20:12:14 +00:00
|
|
|
struct orangefs_inode_s *orangefs_inode;
|
2015-07-17 14:38:15 +00:00
|
|
|
|
2016-02-04 18:48:16 +00:00
|
|
|
orangefs_inode = kmem_cache_alloc(orangefs_inode_cache, GFP_KERNEL);
|
2017-08-17 19:00:07 +00:00
|
|
|
if (!orangefs_inode)
|
2015-07-17 14:38:15 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We want to clear everything except for rw_semaphore and the
|
|
|
|
* vfs_inode.
|
|
|
|
*/
|
2015-11-24 20:12:14 +00:00
|
|
|
memset(&orangefs_inode->refn.khandle, 0, 16);
|
|
|
|
orangefs_inode->refn.fs_id = ORANGEFS_FS_ID_NULL;
|
|
|
|
orangefs_inode->last_failed_block_index_read = 0;
|
|
|
|
memset(orangefs_inode->link_target, 0, sizeof(orangefs_inode->link_target));
|
2015-07-17 14:38:15 +00:00
|
|
|
|
|
|
|
gossip_debug(GOSSIP_SUPER_DEBUG,
|
2015-11-24 20:12:14 +00:00
|
|
|
"orangefs_alloc_inode: allocated %p\n",
|
|
|
|
&orangefs_inode->vfs_inode);
|
|
|
|
return &orangefs_inode->vfs_inode;
|
2015-07-17 14:38:15 +00:00
|
|
|
}
|
|
|
|
|
2019-04-16 15:43:02 +00:00
|
|
|
static void orangefs_free_inode(struct inode *inode)
|
2017-02-24 15:43:36 +00:00
|
|
|
{
|
|
|
|
struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
|
2017-12-12 18:46:30 +00:00
|
|
|
struct orangefs_cached_xattr *cx;
|
|
|
|
struct hlist_node *tmp;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
hash_for_each_safe(orangefs_inode->xattr_cache, i, tmp, cx, node) {
|
|
|
|
hlist_del(&cx->node);
|
|
|
|
kfree(cx);
|
|
|
|
}
|
|
|
|
|
2017-02-24 15:43:36 +00:00
|
|
|
kmem_cache_free(orangefs_inode_cache, orangefs_inode);
|
|
|
|
}
|
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
static void orangefs_destroy_inode(struct inode *inode)
|
2015-07-17 14:38:15 +00:00
|
|
|
{
|
2015-11-24 20:12:14 +00:00
|
|
|
struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
|
2015-07-17 14:38:15 +00:00
|
|
|
|
|
|
|
gossip_debug(GOSSIP_SUPER_DEBUG,
|
|
|
|
"%s: deallocated %p destroying inode %pU\n",
|
2015-11-24 20:12:14 +00:00
|
|
|
__func__, orangefs_inode, get_khandle_from_ino(inode));
|
2015-07-17 14:38:15 +00:00
|
|
|
}
|
|
|
|
|
2018-02-12 20:29:37 +00:00
|
|
|
static int orangefs_write_inode(struct inode *inode,
|
|
|
|
struct writeback_control *wbc)
|
|
|
|
{
|
|
|
|
gossip_debug(GOSSIP_SUPER_DEBUG, "orangefs_write_inode\n");
|
2018-02-13 20:13:46 +00:00
|
|
|
return orangefs_inode_setattr(inode);
|
2018-02-12 20:29:37 +00:00
|
|
|
}
|
|
|
|
|
2015-07-17 14:38:15 +00:00
|
|
|
/*
|
|
|
|
* NOTE: information filled in here is typically reflected in the
|
|
|
|
* output of the system command 'df'
|
|
|
|
*/
|
2015-11-24 20:12:14 +00:00
|
|
|
static int orangefs_statfs(struct dentry *dentry, struct kstatfs *buf)
|
2015-07-17 14:38:15 +00:00
|
|
|
{
|
|
|
|
int ret = -ENOMEM;
|
2015-11-24 20:12:14 +00:00
|
|
|
struct orangefs_kernel_op_s *new_op = NULL;
|
2015-07-17 14:38:15 +00:00
|
|
|
int flags = 0;
|
|
|
|
struct super_block *sb = NULL;
|
|
|
|
|
|
|
|
sb = dentry->d_sb;
|
|
|
|
|
|
|
|
gossip_debug(GOSSIP_SUPER_DEBUG,
|
2018-05-11 21:11:48 +00:00
|
|
|
"%s: called on sb %p (fs_id is %d)\n",
|
|
|
|
__func__,
|
|
|
|
sb,
|
|
|
|
(int)(ORANGEFS_SB(sb)->fs_id));
|
2015-07-17 14:38:15 +00:00
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
new_op = op_alloc(ORANGEFS_VFS_OP_STATFS);
|
2015-07-17 14:38:15 +00:00
|
|
|
if (!new_op)
|
|
|
|
return ret;
|
2015-11-24 20:12:14 +00:00
|
|
|
new_op->upcall.req.statfs.fs_id = ORANGEFS_SB(sb)->fs_id;
|
2015-07-17 14:38:15 +00:00
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
if (ORANGEFS_SB(sb)->flags & ORANGEFS_OPT_INTR)
|
|
|
|
flags = ORANGEFS_OP_INTERRUPTIBLE;
|
2015-07-17 14:38:15 +00:00
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
ret = service_operation(new_op, "orangefs_statfs", flags);
|
2015-07-17 14:38:15 +00:00
|
|
|
|
|
|
|
if (new_op->downcall.status < 0)
|
|
|
|
goto out_op_release;
|
|
|
|
|
|
|
|
gossip_debug(GOSSIP_SUPER_DEBUG,
|
2016-01-13 16:38:14 +00:00
|
|
|
"%s: got %ld blocks available | "
|
|
|
|
"%ld blocks total | %ld block size | "
|
|
|
|
"%ld files total | %ld files avail\n",
|
|
|
|
__func__,
|
2015-07-17 14:38:15 +00:00
|
|
|
(long)new_op->downcall.resp.statfs.blocks_avail,
|
|
|
|
(long)new_op->downcall.resp.statfs.blocks_total,
|
2016-01-13 16:38:14 +00:00
|
|
|
(long)new_op->downcall.resp.statfs.block_size,
|
|
|
|
(long)new_op->downcall.resp.statfs.files_total,
|
|
|
|
(long)new_op->downcall.resp.statfs.files_avail);
|
2015-07-17 14:38:15 +00:00
|
|
|
|
|
|
|
buf->f_type = sb->s_magic;
|
2015-11-24 20:12:14 +00:00
|
|
|
memcpy(&buf->f_fsid, &ORANGEFS_SB(sb)->fs_id, sizeof(buf->f_fsid));
|
2015-07-17 14:38:15 +00:00
|
|
|
buf->f_bsize = new_op->downcall.resp.statfs.block_size;
|
2016-02-20 19:22:40 +00:00
|
|
|
buf->f_namelen = ORANGEFS_NAME_MAX;
|
2015-07-17 14:38:15 +00:00
|
|
|
|
|
|
|
buf->f_blocks = (sector_t) new_op->downcall.resp.statfs.blocks_total;
|
|
|
|
buf->f_bfree = (sector_t) new_op->downcall.resp.statfs.blocks_avail;
|
|
|
|
buf->f_bavail = (sector_t) new_op->downcall.resp.statfs.blocks_avail;
|
|
|
|
buf->f_files = (sector_t) new_op->downcall.resp.statfs.files_total;
|
|
|
|
buf->f_ffree = (sector_t) new_op->downcall.resp.statfs.files_avail;
|
2021-05-18 12:09:13 +00:00
|
|
|
buf->f_frsize = 0;
|
2015-07-17 14:38:15 +00:00
|
|
|
|
|
|
|
out_op_release:
|
|
|
|
op_release(new_op);
|
2018-05-11 21:11:48 +00:00
|
|
|
gossip_debug(GOSSIP_SUPER_DEBUG, "%s: returning %d\n", __func__, ret);
|
2015-07-17 14:38:15 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remount as initiated by VFS layer. We just need to reparse the mount
|
|
|
|
* options, no need to signal pvfs2-client-core about it.
|
|
|
|
*/
|
2015-11-24 20:12:14 +00:00
|
|
|
static int orangefs_remount_fs(struct super_block *sb, int *flags, char *data)
|
2015-07-17 14:38:15 +00:00
|
|
|
{
|
2015-11-24 20:12:14 +00:00
|
|
|
gossip_debug(GOSSIP_SUPER_DEBUG, "orangefs_remount_fs: called\n");
|
2015-07-17 14:38:15 +00:00
|
|
|
return parse_mount_options(sb, data, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remount as initiated by pvfs2-client-core on restart. This is used to
|
|
|
|
* repopulate mount information left from previous pvfs2-client-core.
|
|
|
|
*
|
|
|
|
* the idea here is that given a valid superblock, we're
|
|
|
|
* re-initializing the user space client with the initial mount
|
|
|
|
* information specified when the super block was first initialized.
|
|
|
|
* this is very different than the first initialization/creation of a
|
|
|
|
* superblock. we use the special service_priority_operation to make
|
|
|
|
* sure that the mount gets ahead of any other pending operation that
|
|
|
|
* is waiting for servicing. this means that the pvfs2-client won't
|
|
|
|
* fail to start several times for all other pending operations before
|
|
|
|
* the client regains all of the mount information from us.
|
|
|
|
* NOTE: this function assumes that the request_mutex is already acquired!
|
|
|
|
*/
|
2016-03-25 23:56:34 +00:00
|
|
|
int orangefs_remount(struct orangefs_sb_info_s *orangefs_sb)
|
2015-07-17 14:38:15 +00:00
|
|
|
{
|
2015-11-24 20:12:14 +00:00
|
|
|
struct orangefs_kernel_op_s *new_op;
|
2015-07-17 14:38:15 +00:00
|
|
|
int ret = -EINVAL;
|
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
gossip_debug(GOSSIP_SUPER_DEBUG, "orangefs_remount: called\n");
|
2015-07-17 14:38:15 +00:00
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
new_op = op_alloc(ORANGEFS_VFS_OP_FS_MOUNT);
|
2015-07-17 14:38:15 +00:00
|
|
|
if (!new_op)
|
|
|
|
return -ENOMEM;
|
2015-11-24 20:12:14 +00:00
|
|
|
strncpy(new_op->upcall.req.fs_mount.orangefs_config_server,
|
2016-03-25 23:56:34 +00:00
|
|
|
orangefs_sb->devname,
|
2015-11-24 20:12:14 +00:00
|
|
|
ORANGEFS_MAX_SERVER_ADDR_LEN);
|
2015-07-17 14:38:15 +00:00
|
|
|
|
|
|
|
gossip_debug(GOSSIP_SUPER_DEBUG,
|
2015-11-24 20:12:14 +00:00
|
|
|
"Attempting ORANGEFS Remount via host %s\n",
|
|
|
|
new_op->upcall.req.fs_mount.orangefs_config_server);
|
2015-07-17 14:38:15 +00:00
|
|
|
|
|
|
|
/*
|
2016-02-24 21:54:27 +00:00
|
|
|
* we assume that the calling function has already acquired the
|
2015-07-17 14:38:15 +00:00
|
|
|
* request_mutex to prevent other operations from bypassing
|
|
|
|
* this one
|
|
|
|
*/
|
2015-11-24 20:12:14 +00:00
|
|
|
ret = service_operation(new_op, "orangefs_remount",
|
2016-02-24 21:54:27 +00:00
|
|
|
ORANGEFS_OP_PRIORITY | ORANGEFS_OP_NO_MUTEX);
|
2015-07-17 14:38:15 +00:00
|
|
|
gossip_debug(GOSSIP_SUPER_DEBUG,
|
2015-11-24 20:12:14 +00:00
|
|
|
"orangefs_remount: mount got return value of %d\n",
|
2015-07-17 14:38:15 +00:00
|
|
|
ret);
|
|
|
|
if (ret == 0) {
|
|
|
|
/*
|
|
|
|
* store the id assigned to this sb -- it's just a
|
|
|
|
* short-lived mapping that the system interface uses
|
|
|
|
* to map this superblock to a particular mount entry
|
|
|
|
*/
|
2016-03-25 23:56:34 +00:00
|
|
|
orangefs_sb->id = new_op->downcall.resp.fs_mount.id;
|
|
|
|
orangefs_sb->mount_pending = 0;
|
2015-07-17 14:38:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
op_release(new_op);
|
2016-08-12 16:02:31 +00:00
|
|
|
|
2016-10-03 19:07:36 +00:00
|
|
|
if (orangefs_userspace_version >= 20906) {
|
2016-08-12 16:02:31 +00:00
|
|
|
new_op = op_alloc(ORANGEFS_VFS_OP_FEATURES);
|
|
|
|
if (!new_op)
|
|
|
|
return -ENOMEM;
|
|
|
|
new_op->upcall.req.features.features = 0;
|
orangefs: move features validation to fix filesystem hang
Without this fix (and another to the userspace component itself
described later), the kernel will be unable to process any OrangeFS
requests after the userspace component is restarted (due to a crash or
at the administrator's behest).
The bug here is that inside orangefs_remount, the orangefs_request_mutex
is locked. When the userspace component restarts while the filesystem
is mounted, it sends a ORANGEFS_DEV_REMOUNT_ALL ioctl to the device,
which causes the kernel to send it a few requests aimed at synchronizing
the state between the two. While this is happening the
orangefs_request_mutex is locked to prevent any other requests going
through.
This is only half of the bugfix. The other half is in the userspace
component which outright ignores(!) requests made before it considers
the filesystem remounted, which is after the ioctl returns. Of course
the ioctl doesn't return until after the userspace component responds to
the request it ignores. The userspace component has been changed to
allow ORANGEFS_VFS_OP_FEATURES regardless of the mount status.
Mike Marshall says:
"I've tested this patch against the fixed userspace part. This patch is
real important, I hope it can make it into 4.11...
Here's what happens when the userspace daemon is restarted, without
the patch:
=============================================
[ INFO: possible recursive locking detected ]
[ 4.10.0-00007-ge98bdb3 #1 Not tainted ]
---------------------------------------------
pvfs2-client-co/29032 is trying to acquire lock:
(orangefs_request_mutex){+.+.+.}, at: service_operation+0x3c7/0x7b0 [orangefs]
but task is already holding lock:
(orangefs_request_mutex){+.+.+.}, at: dispatch_ioctl_command+0x1bf/0x330 [orangefs]
CPU: 0 PID: 29032 Comm: pvfs2-client-co Not tainted 4.10.0-00007-ge98bdb3 #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.9.3-1.fc25 04/01/2014
Call Trace:
__lock_acquire+0x7eb/0x1290
lock_acquire+0xe8/0x1d0
mutex_lock_killable_nested+0x6f/0x6e0
service_operation+0x3c7/0x7b0 [orangefs]
orangefs_remount+0xea/0x150 [orangefs]
dispatch_ioctl_command+0x227/0x330 [orangefs]
orangefs_devreq_ioctl+0x29/0x70 [orangefs]
do_vfs_ioctl+0xa3/0x6e0
SyS_ioctl+0x79/0x90"
Signed-off-by: Martin Brandenburg <martin@omnibond.com>
Acked-by: Mike Marshall <hubcap@omnibond.com>
Cc: stable@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-04-06 22:11:00 +00:00
|
|
|
ret = service_operation(new_op, "orangefs_features",
|
|
|
|
ORANGEFS_OP_PRIORITY | ORANGEFS_OP_NO_MUTEX);
|
|
|
|
if (!ret)
|
|
|
|
orangefs_features =
|
|
|
|
new_op->downcall.resp.features.features;
|
|
|
|
else
|
|
|
|
orangefs_features = 0;
|
2016-08-12 16:02:31 +00:00
|
|
|
op_release(new_op);
|
|
|
|
} else {
|
|
|
|
orangefs_features = 0;
|
|
|
|
}
|
|
|
|
|
2015-07-17 14:38:15 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int fsid_key_table_initialize(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fsid_key_table_finalize(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
static const struct super_operations orangefs_s_ops = {
|
|
|
|
.alloc_inode = orangefs_alloc_inode,
|
2019-04-16 15:43:02 +00:00
|
|
|
.free_inode = orangefs_free_inode,
|
2015-11-24 20:12:14 +00:00
|
|
|
.destroy_inode = orangefs_destroy_inode,
|
2018-02-12 20:29:37 +00:00
|
|
|
.write_inode = orangefs_write_inode,
|
2015-07-17 14:38:15 +00:00
|
|
|
.drop_inode = generic_delete_inode,
|
2015-11-24 20:12:14 +00:00
|
|
|
.statfs = orangefs_statfs,
|
|
|
|
.remount_fs = orangefs_remount_fs,
|
2017-07-05 15:25:45 +00:00
|
|
|
.show_options = orangefs_show_options,
|
2015-07-17 14:38:15 +00:00
|
|
|
};
|
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
static struct dentry *orangefs_fh_to_dentry(struct super_block *sb,
|
2015-07-17 14:38:15 +00:00
|
|
|
struct fid *fid,
|
|
|
|
int fh_len,
|
|
|
|
int fh_type)
|
|
|
|
{
|
2015-11-24 20:12:14 +00:00
|
|
|
struct orangefs_object_kref refn;
|
2015-07-17 14:38:15 +00:00
|
|
|
|
|
|
|
if (fh_len < 5 || fh_type > 2)
|
|
|
|
return NULL;
|
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
ORANGEFS_khandle_from(&(refn.khandle), fid->raw, 16);
|
2015-07-17 14:38:15 +00:00
|
|
|
refn.fs_id = (u32) fid->raw[4];
|
|
|
|
gossip_debug(GOSSIP_SUPER_DEBUG,
|
|
|
|
"fh_to_dentry: handle %pU, fs_id %d\n",
|
|
|
|
&refn.khandle,
|
|
|
|
refn.fs_id);
|
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
return d_obtain_alias(orangefs_iget(sb, &refn));
|
2015-07-17 14:38:15 +00:00
|
|
|
}
|
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
static int orangefs_encode_fh(struct inode *inode,
|
2015-07-17 14:38:15 +00:00
|
|
|
__u32 *fh,
|
|
|
|
int *max_len,
|
|
|
|
struct inode *parent)
|
|
|
|
{
|
|
|
|
int len = parent ? 10 : 5;
|
|
|
|
int type = 1;
|
2015-11-24 20:12:14 +00:00
|
|
|
struct orangefs_object_kref refn;
|
2015-07-17 14:38:15 +00:00
|
|
|
|
|
|
|
if (*max_len < len) {
|
2018-01-26 19:07:12 +00:00
|
|
|
gossip_err("fh buffer is too small for encoding\n");
|
2015-07-17 14:38:15 +00:00
|
|
|
*max_len = len;
|
|
|
|
type = 255;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
refn = ORANGEFS_I(inode)->refn;
|
|
|
|
ORANGEFS_khandle_to(&refn.khandle, fh, 16);
|
2015-07-17 14:38:15 +00:00
|
|
|
fh[4] = refn.fs_id;
|
|
|
|
|
|
|
|
gossip_debug(GOSSIP_SUPER_DEBUG,
|
|
|
|
"Encoding fh: handle %pU, fsid %u\n",
|
|
|
|
&refn.khandle,
|
|
|
|
refn.fs_id);
|
|
|
|
|
|
|
|
|
|
|
|
if (parent) {
|
2015-11-24 20:12:14 +00:00
|
|
|
refn = ORANGEFS_I(parent)->refn;
|
|
|
|
ORANGEFS_khandle_to(&refn.khandle, (char *) fh + 20, 16);
|
2015-07-17 14:38:15 +00:00
|
|
|
fh[9] = refn.fs_id;
|
|
|
|
|
|
|
|
type = 2;
|
|
|
|
gossip_debug(GOSSIP_SUPER_DEBUG,
|
|
|
|
"Encoding parent: handle %pU, fsid %u\n",
|
|
|
|
&refn.khandle,
|
|
|
|
refn.fs_id);
|
|
|
|
}
|
|
|
|
*max_len = len;
|
|
|
|
|
|
|
|
out:
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
2016-01-01 09:01:52 +00:00
|
|
|
static const struct export_operations orangefs_export_ops = {
|
2015-11-24 20:12:14 +00:00
|
|
|
.encode_fh = orangefs_encode_fh,
|
|
|
|
.fh_to_dentry = orangefs_fh_to_dentry,
|
2015-07-17 14:38:15 +00:00
|
|
|
};
|
|
|
|
|
2017-04-25 19:38:05 +00:00
|
|
|
static int orangefs_unmount(int id, __s32 fs_id, const char *devname)
|
|
|
|
{
|
|
|
|
struct orangefs_kernel_op_s *op;
|
|
|
|
int r;
|
|
|
|
op = op_alloc(ORANGEFS_VFS_OP_FS_UMOUNT);
|
|
|
|
if (!op)
|
|
|
|
return -ENOMEM;
|
|
|
|
op->upcall.req.fs_umount.id = id;
|
|
|
|
op->upcall.req.fs_umount.fs_id = fs_id;
|
|
|
|
strncpy(op->upcall.req.fs_umount.orangefs_config_server,
|
2018-01-08 12:22:33 +00:00
|
|
|
devname, ORANGEFS_MAX_SERVER_ADDR_LEN - 1);
|
2017-04-25 19:38:05 +00:00
|
|
|
r = service_operation(op, "orangefs_fs_umount", 0);
|
|
|
|
/* Not much to do about an error here. */
|
|
|
|
if (r)
|
|
|
|
gossip_err("orangefs_unmount: service_operation %d\n", r);
|
|
|
|
op_release(op);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
static int orangefs_fill_sb(struct super_block *sb,
|
|
|
|
struct orangefs_fs_mount_response *fs_mount,
|
2015-10-09 00:22:43 +00:00
|
|
|
void *data, int silent)
|
2015-07-17 14:38:15 +00:00
|
|
|
{
|
2018-02-12 20:28:42 +00:00
|
|
|
int ret;
|
|
|
|
struct inode *root;
|
|
|
|
struct dentry *root_dentry;
|
2015-11-24 20:12:14 +00:00
|
|
|
struct orangefs_object_kref root_object;
|
2015-07-17 14:38:15 +00:00
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
ORANGEFS_SB(sb)->sb = sb;
|
2015-07-17 14:38:15 +00:00
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
ORANGEFS_SB(sb)->root_khandle = fs_mount->root_khandle;
|
|
|
|
ORANGEFS_SB(sb)->fs_id = fs_mount->fs_id;
|
|
|
|
ORANGEFS_SB(sb)->id = fs_mount->id;
|
2015-07-17 14:38:15 +00:00
|
|
|
|
2015-10-09 00:22:43 +00:00
|
|
|
if (data) {
|
|
|
|
ret = parse_mount_options(sb, data, silent);
|
2015-07-17 14:38:15 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Hang the xattr handlers off the superblock */
|
2015-11-24 20:12:14 +00:00
|
|
|
sb->s_xattr = orangefs_xattr_handlers;
|
|
|
|
sb->s_magic = ORANGEFS_SUPER_MAGIC;
|
|
|
|
sb->s_op = &orangefs_s_ops;
|
|
|
|
sb->s_d_op = &orangefs_dentry_operations;
|
2015-07-17 14:38:15 +00:00
|
|
|
|
2018-05-31 16:36:59 +00:00
|
|
|
sb->s_blocksize = PAGE_SIZE;
|
|
|
|
sb->s_blocksize_bits = PAGE_SHIFT;
|
2015-07-17 14:38:15 +00:00
|
|
|
sb->s_maxbytes = MAX_LFS_FILESIZE;
|
|
|
|
|
2018-02-12 20:28:42 +00:00
|
|
|
ret = super_setup_bdi(sb);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
root_object.khandle = ORANGEFS_SB(sb)->root_khandle;
|
|
|
|
root_object.fs_id = ORANGEFS_SB(sb)->fs_id;
|
2015-07-17 14:38:15 +00:00
|
|
|
gossip_debug(GOSSIP_SUPER_DEBUG,
|
|
|
|
"get inode %pU, fsid %d\n",
|
|
|
|
&root_object.khandle,
|
|
|
|
root_object.fs_id);
|
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
root = orangefs_iget(sb, &root_object);
|
2015-07-17 14:38:15 +00:00
|
|
|
if (IS_ERR(root))
|
|
|
|
return PTR_ERR(root);
|
|
|
|
|
|
|
|
gossip_debug(GOSSIP_SUPER_DEBUG,
|
|
|
|
"Allocated root inode [%p] with mode %x\n",
|
|
|
|
root,
|
|
|
|
root->i_mode);
|
|
|
|
|
|
|
|
/* allocates and places root dentry in dcache */
|
|
|
|
root_dentry = d_make_root(root);
|
2015-10-09 00:18:00 +00:00
|
|
|
if (!root_dentry)
|
2015-07-17 14:38:15 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
sb->s_export_op = &orangefs_export_ops;
|
2015-07-17 14:38:15 +00:00
|
|
|
sb->s_root = root_dentry;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
struct dentry *orangefs_mount(struct file_system_type *fst,
|
2015-07-17 14:38:15 +00:00
|
|
|
int flags,
|
|
|
|
const char *devname,
|
|
|
|
void *data)
|
|
|
|
{
|
2021-09-10 12:25:34 +00:00
|
|
|
int ret;
|
2015-07-17 14:38:15 +00:00
|
|
|
struct super_block *sb = ERR_PTR(-EINVAL);
|
2015-11-24 20:12:14 +00:00
|
|
|
struct orangefs_kernel_op_s *new_op;
|
2015-09-29 19:26:37 +00:00
|
|
|
struct dentry *d = ERR_PTR(-EINVAL);
|
2015-07-17 14:38:15 +00:00
|
|
|
|
|
|
|
gossip_debug(GOSSIP_SUPER_DEBUG,
|
2015-11-24 20:12:14 +00:00
|
|
|
"orangefs_mount: called with devname %s\n",
|
2015-07-17 14:38:15 +00:00
|
|
|
devname);
|
|
|
|
|
|
|
|
if (!devname) {
|
|
|
|
gossip_err("ERROR: device name not specified.\n");
|
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
}
|
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
new_op = op_alloc(ORANGEFS_VFS_OP_FS_MOUNT);
|
2015-07-17 14:38:15 +00:00
|
|
|
if (!new_op)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
strncpy(new_op->upcall.req.fs_mount.orangefs_config_server,
|
2015-07-17 14:38:15 +00:00
|
|
|
devname,
|
2018-01-08 12:22:33 +00:00
|
|
|
ORANGEFS_MAX_SERVER_ADDR_LEN - 1);
|
2015-07-17 14:38:15 +00:00
|
|
|
|
|
|
|
gossip_debug(GOSSIP_SUPER_DEBUG,
|
2015-11-24 20:12:14 +00:00
|
|
|
"Attempting ORANGEFS Mount via host %s\n",
|
|
|
|
new_op->upcall.req.fs_mount.orangefs_config_server);
|
2015-07-17 14:38:15 +00:00
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
ret = service_operation(new_op, "orangefs_mount", 0);
|
2015-07-17 14:38:15 +00:00
|
|
|
gossip_debug(GOSSIP_SUPER_DEBUG,
|
2015-11-24 20:12:14 +00:00
|
|
|
"orangefs_mount: mount got return value of %d\n", ret);
|
2015-07-17 14:38:15 +00:00
|
|
|
if (ret)
|
|
|
|
goto free_op;
|
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
if (new_op->downcall.resp.fs_mount.fs_id == ORANGEFS_FS_ID_NULL) {
|
2015-07-17 14:38:15 +00:00
|
|
|
gossip_err("ERROR: Retrieved null fs_id\n");
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto free_op;
|
|
|
|
}
|
|
|
|
|
2015-09-29 19:26:37 +00:00
|
|
|
sb = sget(fst, NULL, set_anon_super, flags, NULL);
|
|
|
|
|
|
|
|
if (IS_ERR(sb)) {
|
|
|
|
d = ERR_CAST(sb);
|
2017-04-25 19:38:05 +00:00
|
|
|
orangefs_unmount(new_op->downcall.resp.fs_mount.id,
|
|
|
|
new_op->downcall.resp.fs_mount.fs_id, devname);
|
2015-07-17 14:38:15 +00:00
|
|
|
goto free_op;
|
|
|
|
}
|
|
|
|
|
2018-02-12 20:28:42 +00:00
|
|
|
/* alloc and init our private orangefs sb info */
|
|
|
|
sb->s_fs_info = kzalloc(sizeof(struct orangefs_sb_info_s), GFP_KERNEL);
|
|
|
|
if (!ORANGEFS_SB(sb)) {
|
|
|
|
d = ERR_PTR(-ENOMEM);
|
2021-09-07 11:41:05 +00:00
|
|
|
goto free_sb_and_op;
|
2018-02-12 20:28:42 +00:00
|
|
|
}
|
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
ret = orangefs_fill_sb(sb,
|
2015-10-09 00:22:43 +00:00
|
|
|
&new_op->downcall.resp.fs_mount, data,
|
2017-11-27 21:05:09 +00:00
|
|
|
flags & SB_SILENT ? 1 : 0);
|
2015-09-29 19:26:37 +00:00
|
|
|
|
|
|
|
if (ret) {
|
|
|
|
d = ERR_PTR(ret);
|
2017-04-14 18:22:41 +00:00
|
|
|
goto free_sb_and_op;
|
2015-09-29 19:26:37 +00:00
|
|
|
}
|
2015-07-17 14:38:15 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* on successful mount, store the devname and data
|
|
|
|
* used
|
|
|
|
*/
|
2015-11-24 20:12:14 +00:00
|
|
|
strncpy(ORANGEFS_SB(sb)->devname,
|
2015-07-17 14:38:15 +00:00
|
|
|
devname,
|
2018-01-08 12:22:33 +00:00
|
|
|
ORANGEFS_MAX_SERVER_ADDR_LEN - 1);
|
2015-07-17 14:38:15 +00:00
|
|
|
|
|
|
|
/* mount_pending must be cleared */
|
2015-11-24 20:12:14 +00:00
|
|
|
ORANGEFS_SB(sb)->mount_pending = 0;
|
2015-07-17 14:38:15 +00:00
|
|
|
|
|
|
|
/*
|
2015-11-24 20:12:14 +00:00
|
|
|
* finally, add this sb to our list of known orangefs
|
2015-07-17 14:38:15 +00:00
|
|
|
* sb's
|
|
|
|
*/
|
2016-03-25 23:56:34 +00:00
|
|
|
gossip_debug(GOSSIP_SUPER_DEBUG,
|
|
|
|
"Adding SB %p to orangefs superblocks\n",
|
|
|
|
ORANGEFS_SB(sb));
|
|
|
|
spin_lock(&orangefs_superblocks_lock);
|
|
|
|
list_add_tail(&ORANGEFS_SB(sb)->list, &orangefs_superblocks);
|
|
|
|
spin_unlock(&orangefs_superblocks_lock);
|
2015-07-17 14:38:15 +00:00
|
|
|
op_release(new_op);
|
2016-08-12 16:02:31 +00:00
|
|
|
|
2017-04-14 18:22:41 +00:00
|
|
|
/* Must be removed from the list now. */
|
|
|
|
ORANGEFS_SB(sb)->no_list = 0;
|
|
|
|
|
2016-10-03 19:07:36 +00:00
|
|
|
if (orangefs_userspace_version >= 20906) {
|
2016-08-12 16:02:31 +00:00
|
|
|
new_op = op_alloc(ORANGEFS_VFS_OP_FEATURES);
|
|
|
|
if (!new_op)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
new_op->upcall.req.features.features = 0;
|
|
|
|
ret = service_operation(new_op, "orangefs_features", 0);
|
|
|
|
orangefs_features = new_op->downcall.resp.features.features;
|
|
|
|
op_release(new_op);
|
|
|
|
} else {
|
|
|
|
orangefs_features = 0;
|
|
|
|
}
|
|
|
|
|
2015-09-29 19:26:37 +00:00
|
|
|
return dget(sb->s_root);
|
2015-07-17 14:38:15 +00:00
|
|
|
|
2017-04-14 18:22:41 +00:00
|
|
|
free_sb_and_op:
|
|
|
|
/* Will call orangefs_kill_sb with sb not in list. */
|
|
|
|
ORANGEFS_SB(sb)->no_list = 1;
|
2017-04-25 19:38:05 +00:00
|
|
|
/* ORANGEFS_VFS_OP_FS_UMOUNT is done by orangefs_kill_sb. */
|
2017-04-14 18:22:41 +00:00
|
|
|
deactivate_locked_super(sb);
|
2015-07-17 14:38:15 +00:00
|
|
|
free_op:
|
2015-11-24 20:12:14 +00:00
|
|
|
gossip_err("orangefs_mount: mount request failed with %d\n", ret);
|
2015-07-17 14:38:15 +00:00
|
|
|
if (ret == -EINVAL) {
|
2015-11-24 20:12:14 +00:00
|
|
|
gossip_err("Ensure that all orangefs-servers have the same FS configuration files\n");
|
2015-07-17 14:38:15 +00:00
|
|
|
gossip_err("Look at pvfs2-client-core log file (typically /tmp/pvfs2-client.log) for more details\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
op_release(new_op);
|
|
|
|
|
2015-09-29 19:26:37 +00:00
|
|
|
return d;
|
2015-07-17 14:38:15 +00:00
|
|
|
}
|
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
void orangefs_kill_sb(struct super_block *sb)
|
2015-07-17 14:38:15 +00:00
|
|
|
{
|
2017-04-25 19:38:05 +00:00
|
|
|
int r;
|
2015-11-24 20:12:14 +00:00
|
|
|
gossip_debug(GOSSIP_SUPER_DEBUG, "orangefs_kill_sb: called\n");
|
2015-07-17 14:38:15 +00:00
|
|
|
|
2016-02-17 02:08:29 +00:00
|
|
|
/* provided sb cleanup */
|
|
|
|
kill_anon_super(sb);
|
|
|
|
|
2018-04-03 04:13:17 +00:00
|
|
|
if (!ORANGEFS_SB(sb)) {
|
|
|
|
mutex_lock(&orangefs_request_mutex);
|
|
|
|
mutex_unlock(&orangefs_request_mutex);
|
|
|
|
return;
|
|
|
|
}
|
2015-07-17 14:38:15 +00:00
|
|
|
/*
|
|
|
|
* issue the unmount to userspace to tell it to remove the
|
|
|
|
* dynamic mount info it has for this superblock
|
|
|
|
*/
|
2017-04-25 19:38:05 +00:00
|
|
|
r = orangefs_unmount(ORANGEFS_SB(sb)->id, ORANGEFS_SB(sb)->fs_id,
|
|
|
|
ORANGEFS_SB(sb)->devname);
|
|
|
|
if (!r)
|
|
|
|
ORANGEFS_SB(sb)->mount_pending = 1;
|
2015-07-17 14:38:15 +00:00
|
|
|
|
2017-04-14 18:22:41 +00:00
|
|
|
if (!ORANGEFS_SB(sb)->no_list) {
|
|
|
|
/* remove the sb from our list of orangefs specific sb's */
|
|
|
|
spin_lock(&orangefs_superblocks_lock);
|
|
|
|
/* not list_del_init */
|
|
|
|
__list_del_entry(&ORANGEFS_SB(sb)->list);
|
|
|
|
ORANGEFS_SB(sb)->list.prev = NULL;
|
|
|
|
spin_unlock(&orangefs_superblocks_lock);
|
|
|
|
}
|
2016-03-25 23:56:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* make sure that ORANGEFS_DEV_REMOUNT_ALL loop that might've seen us
|
|
|
|
* gets completed before we free the dang thing.
|
|
|
|
*/
|
2016-08-16 15:38:14 +00:00
|
|
|
mutex_lock(&orangefs_request_mutex);
|
|
|
|
mutex_unlock(&orangefs_request_mutex);
|
2015-07-17 14:38:15 +00:00
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
/* free the orangefs superblock private data */
|
|
|
|
kfree(ORANGEFS_SB(sb));
|
2015-07-17 14:38:15 +00:00
|
|
|
}
|
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
int orangefs_inode_cache_initialize(void)
|
2015-07-17 14:38:15 +00:00
|
|
|
{
|
orangefs: Define usercopy region in orangefs_inode_cache slab cache
orangefs symlink pathnames, stored in struct orangefs_inode_s.link_target
and therefore contained in the orangefs_inode_cache, need to be copied
to/from userspace.
cache object allocation:
fs/orangefs/super.c:
orangefs_alloc_inode(...):
...
orangefs_inode = kmem_cache_alloc(orangefs_inode_cache, ...);
...
return &orangefs_inode->vfs_inode;
fs/orangefs/orangefs-utils.c:
exofs_symlink(...):
...
inode->i_link = orangefs_inode->link_target;
example usage trace:
readlink_copy+0x43/0x70
vfs_readlink+0x62/0x110
SyS_readlinkat+0x100/0x130
fs/namei.c:
readlink_copy(..., link):
...
copy_to_user(..., link, len);
(inlined in vfs_readlink)
generic_readlink(dentry, ...):
struct inode *inode = d_inode(dentry);
const char *link = inode->i_link;
...
readlink_copy(..., link);
In support of usercopy hardening, this patch defines a region in the
orangefs_inode_cache slab cache in which userspace copy operations are
allowed.
This region is known as the slab cache's usercopy region. Slab caches
can now check that each dynamically sized copy operation involving
cache-managed memory falls entirely within the slab's usercopy region.
This patch is modified from Brad Spengler/PaX Team's PAX_USERCOPY
whitelisting code in the last public patch of grsecurity/PaX based on my
understanding of the code. Changes or omissions from the original code are
mine and don't reflect the original grsecurity/PaX code.
Signed-off-by: David Windsor <dave@nullcore.net>
[kees: adjust commit log, provide usage trace]
Cc: Mike Marshall <hubcap@omnibond.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
2017-06-11 02:50:39 +00:00
|
|
|
orangefs_inode_cache = kmem_cache_create_usercopy(
|
|
|
|
"orangefs_inode_cache",
|
|
|
|
sizeof(struct orangefs_inode_s),
|
|
|
|
0,
|
|
|
|
ORANGEFS_CACHE_CREATE_FLAGS,
|
|
|
|
offsetof(struct orangefs_inode_s,
|
|
|
|
link_target),
|
|
|
|
sizeof_field(struct orangefs_inode_s,
|
|
|
|
link_target),
|
|
|
|
orangefs_inode_cache_ctor);
|
2015-07-17 14:38:15 +00:00
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
if (!orangefs_inode_cache) {
|
|
|
|
gossip_err("Cannot create orangefs_inode_cache\n");
|
2015-07-17 14:38:15 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-11-24 20:12:14 +00:00
|
|
|
int orangefs_inode_cache_finalize(void)
|
2015-07-17 14:38:15 +00:00
|
|
|
{
|
2015-11-24 20:12:14 +00:00
|
|
|
kmem_cache_destroy(orangefs_inode_cache);
|
2015-07-17 14:38:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|