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 17:07:57 +03:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2014 Christoph Hellwig.
|
|
|
|
*/
|
2016-03-04 22:46:17 +03:00
|
|
|
#include <linux/blkdev.h>
|
2014-09-23 14:38:48 +04:00
|
|
|
#include <linux/kmod.h>
|
|
|
|
#include <linux/file.h>
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
#include <linux/jhash.h>
|
|
|
|
#include <linux/sched.h>
|
2014-09-23 14:38:48 +04:00
|
|
|
#include <linux/sunrpc/addr.h>
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
|
|
|
|
#include "pnfs.h"
|
|
|
|
#include "netns.h"
|
2014-08-17 04:02:22 +04:00
|
|
|
#include "trace.h"
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
|
|
|
|
#define NFSDDBG_FACILITY NFSDDBG_PNFS
|
|
|
|
|
|
|
|
struct nfs4_layout {
|
|
|
|
struct list_head lo_perstate;
|
|
|
|
struct nfs4_layout_stateid *lo_state;
|
|
|
|
struct nfsd4_layout_seg lo_seg;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct kmem_cache *nfs4_layout_cache;
|
|
|
|
static struct kmem_cache *nfs4_layout_stateid_cache;
|
|
|
|
|
2015-11-22 00:57:39 +03:00
|
|
|
static const struct nfsd4_callback_ops nfsd4_cb_layout_ops;
|
2014-09-23 14:38:48 +04:00
|
|
|
static const struct lock_manager_operations nfsd4_layouts_lm_ops;
|
|
|
|
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
const struct nfsd4_layout_ops *nfsd4_layout_ops[LAYOUT_TYPE_MAX] = {
|
2016-06-14 23:41:28 +03:00
|
|
|
#ifdef CONFIG_NFSD_FLEXFILELAYOUT
|
|
|
|
[LAYOUT_FLEX_FILES] = &ff_layout_ops,
|
|
|
|
#endif
|
2016-03-04 22:46:16 +03:00
|
|
|
#ifdef CONFIG_NFSD_BLOCKLAYOUT
|
2015-01-21 13:40:00 +03:00
|
|
|
[LAYOUT_BLOCK_VOLUME] = &bl_layout_ops,
|
2016-03-04 22:46:16 +03:00
|
|
|
#endif
|
2016-03-04 22:46:17 +03:00
|
|
|
#ifdef CONFIG_NFSD_SCSILAYOUT
|
|
|
|
[LAYOUT_SCSI] = &scsi_layout_ops,
|
|
|
|
#endif
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/* pNFS device ID to export fsid mapping */
|
|
|
|
#define DEVID_HASH_BITS 8
|
|
|
|
#define DEVID_HASH_SIZE (1 << DEVID_HASH_BITS)
|
|
|
|
#define DEVID_HASH_MASK (DEVID_HASH_SIZE - 1)
|
|
|
|
static u64 nfsd_devid_seq = 1;
|
|
|
|
static struct list_head nfsd_devid_hash[DEVID_HASH_SIZE];
|
|
|
|
static DEFINE_SPINLOCK(nfsd_devid_lock);
|
|
|
|
|
|
|
|
static inline u32 devid_hashfn(u64 idx)
|
|
|
|
{
|
|
|
|
return jhash_2words(idx, idx >> 32, 0) & DEVID_HASH_MASK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
nfsd4_alloc_devid_map(const struct svc_fh *fhp)
|
|
|
|
{
|
|
|
|
const struct knfsd_fh *fh = &fhp->fh_handle;
|
|
|
|
size_t fsid_len = key_len(fh->fh_fsid_type);
|
|
|
|
struct nfsd4_deviceid_map *map, *old;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
map = kzalloc(sizeof(*map) + fsid_len, GFP_KERNEL);
|
|
|
|
if (!map)
|
|
|
|
return;
|
|
|
|
|
|
|
|
map->fsid_type = fh->fh_fsid_type;
|
|
|
|
memcpy(&map->fsid, fh->fh_fsid, fsid_len);
|
|
|
|
|
|
|
|
spin_lock(&nfsd_devid_lock);
|
|
|
|
if (fhp->fh_export->ex_devid_map)
|
|
|
|
goto out_unlock;
|
|
|
|
|
|
|
|
for (i = 0; i < DEVID_HASH_SIZE; i++) {
|
|
|
|
list_for_each_entry(old, &nfsd_devid_hash[i], hash) {
|
|
|
|
if (old->fsid_type != fh->fh_fsid_type)
|
|
|
|
continue;
|
|
|
|
if (memcmp(old->fsid, fh->fh_fsid,
|
|
|
|
key_len(old->fsid_type)))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
fhp->fh_export->ex_devid_map = old;
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
map->idx = nfsd_devid_seq++;
|
|
|
|
list_add_tail_rcu(&map->hash, &nfsd_devid_hash[devid_hashfn(map->idx)]);
|
|
|
|
fhp->fh_export->ex_devid_map = map;
|
|
|
|
map = NULL;
|
|
|
|
|
|
|
|
out_unlock:
|
|
|
|
spin_unlock(&nfsd_devid_lock);
|
|
|
|
kfree(map);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct nfsd4_deviceid_map *
|
|
|
|
nfsd4_find_devid_map(int idx)
|
|
|
|
{
|
|
|
|
struct nfsd4_deviceid_map *map, *ret = NULL;
|
|
|
|
|
|
|
|
rcu_read_lock();
|
|
|
|
list_for_each_entry_rcu(map, &nfsd_devid_hash[devid_hashfn(idx)], hash)
|
|
|
|
if (map->idx == idx)
|
|
|
|
ret = map;
|
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
nfsd4_set_deviceid(struct nfsd4_deviceid *id, const struct svc_fh *fhp,
|
|
|
|
u32 device_generation)
|
|
|
|
{
|
|
|
|
if (!fhp->fh_export->ex_devid_map) {
|
|
|
|
nfsd4_alloc_devid_map(fhp);
|
|
|
|
if (!fhp->fh_export->ex_devid_map)
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
id->fsid_idx = fhp->fh_export->ex_devid_map->idx;
|
|
|
|
id->generation = device_generation;
|
|
|
|
id->pad = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nfsd4_setup_layout_type(struct svc_export *exp)
|
|
|
|
{
|
2016-06-14 23:41:28 +03:00
|
|
|
#if defined(CONFIG_NFSD_BLOCKLAYOUT) || defined(CONFIG_NFSD_SCSILAYOUT)
|
2015-01-21 13:40:00 +03:00
|
|
|
struct super_block *sb = exp->ex_path.mnt->mnt_sb;
|
2016-06-14 23:41:28 +03:00
|
|
|
#endif
|
2015-01-21 13:40:00 +03:00
|
|
|
|
2015-03-30 19:46:29 +03:00
|
|
|
if (!(exp->ex_flags & NFSEXP_PNFS))
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
return;
|
2015-01-21 13:40:00 +03:00
|
|
|
|
2016-06-14 23:41:28 +03:00
|
|
|
#ifdef CONFIG_NFSD_FLEXFILELAYOUT
|
2016-07-10 22:55:58 +03:00
|
|
|
exp->ex_layout_types |= 1 << LAYOUT_FLEX_FILES;
|
2016-06-14 23:41:28 +03:00
|
|
|
#endif
|
2016-03-04 22:46:16 +03:00
|
|
|
#ifdef CONFIG_NFSD_BLOCKLAYOUT
|
2015-01-21 13:40:00 +03:00
|
|
|
if (sb->s_export_op->get_uuid &&
|
|
|
|
sb->s_export_op->map_blocks &&
|
|
|
|
sb->s_export_op->commit_blocks)
|
2016-07-10 22:55:58 +03:00
|
|
|
exp->ex_layout_types |= 1 << LAYOUT_BLOCK_VOLUME;
|
2016-03-04 22:46:16 +03:00
|
|
|
#endif
|
2016-03-04 22:46:17 +03:00
|
|
|
#ifdef CONFIG_NFSD_SCSILAYOUT
|
|
|
|
if (sb->s_export_op->map_blocks &&
|
|
|
|
sb->s_export_op->commit_blocks &&
|
2018-06-19 11:57:24 +03:00
|
|
|
sb->s_bdev && sb->s_bdev->bd_disk->fops->pr_ops &&
|
|
|
|
blk_queue_scsi_passthrough(sb->s_bdev->bd_disk->queue))
|
2016-07-10 22:55:58 +03:00
|
|
|
exp->ex_layout_types |= 1 << LAYOUT_SCSI;
|
2016-03-04 22:46:17 +03:00
|
|
|
#endif
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
nfsd4_free_layout_stateid(struct nfs4_stid *stid)
|
|
|
|
{
|
|
|
|
struct nfs4_layout_stateid *ls = layoutstateid(stid);
|
|
|
|
struct nfs4_client *clp = ls->ls_stid.sc_client;
|
|
|
|
struct nfs4_file *fp = ls->ls_stid.sc_file;
|
|
|
|
|
2018-03-27 17:53:11 +03:00
|
|
|
trace_nfsd_layoutstate_free(&ls->ls_stid.sc_stateid);
|
2014-08-17 04:02:22 +04:00
|
|
|
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
spin_lock(&clp->cl_lock);
|
|
|
|
list_del_init(&ls->ls_perclnt);
|
|
|
|
spin_unlock(&clp->cl_lock);
|
|
|
|
|
|
|
|
spin_lock(&fp->fi_lock);
|
|
|
|
list_del_init(&ls->ls_perfile);
|
|
|
|
spin_unlock(&fp->fi_lock);
|
|
|
|
|
2016-08-11 20:36:22 +03:00
|
|
|
if (!nfsd4_layout_ops[ls->ls_layout_type]->disable_recalls)
|
2019-08-18 21:18:53 +03:00
|
|
|
vfs_setlease(ls->ls_file->nf_file, F_UNLCK, NULL, (void **)&ls);
|
|
|
|
nfsd_file_put(ls->ls_file);
|
2014-09-23 14:38:48 +04:00
|
|
|
|
|
|
|
if (ls->ls_recalled)
|
|
|
|
atomic_dec(&ls->ls_stid.sc_file->fi_lo_recalls);
|
|
|
|
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
kmem_cache_free(nfs4_layout_stateid_cache, ls);
|
|
|
|
}
|
|
|
|
|
2014-09-23 14:38:48 +04:00
|
|
|
static int
|
|
|
|
nfsd4_layout_setlease(struct nfs4_layout_stateid *ls)
|
|
|
|
{
|
|
|
|
struct file_lock *fl;
|
|
|
|
int status;
|
|
|
|
|
2016-08-11 20:36:22 +03:00
|
|
|
if (nfsd4_layout_ops[ls->ls_layout_type]->disable_recalls)
|
|
|
|
return 0;
|
|
|
|
|
2014-09-23 14:38:48 +04:00
|
|
|
fl = locks_alloc_lock();
|
|
|
|
if (!fl)
|
|
|
|
return -ENOMEM;
|
|
|
|
locks_init_lock(fl);
|
|
|
|
fl->fl_lmops = &nfsd4_layouts_lm_ops;
|
|
|
|
fl->fl_flags = FL_LAYOUT;
|
|
|
|
fl->fl_type = F_RDLCK;
|
|
|
|
fl->fl_end = OFFSET_MAX;
|
|
|
|
fl->fl_owner = ls;
|
|
|
|
fl->fl_pid = current->tgid;
|
2019-08-18 21:18:53 +03:00
|
|
|
fl->fl_file = ls->ls_file->nf_file;
|
2014-09-23 14:38:48 +04:00
|
|
|
|
|
|
|
status = vfs_setlease(fl->fl_file, fl->fl_type, &fl, NULL);
|
|
|
|
if (status) {
|
|
|
|
locks_free_lock(fl);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
BUG_ON(fl != NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
static struct nfs4_layout_stateid *
|
|
|
|
nfsd4_alloc_layout_stateid(struct nfsd4_compound_state *cstate,
|
|
|
|
struct nfs4_stid *parent, u32 layout_type)
|
|
|
|
{
|
|
|
|
struct nfs4_client *clp = cstate->clp;
|
|
|
|
struct nfs4_file *fp = parent->sc_file;
|
|
|
|
struct nfs4_layout_stateid *ls;
|
|
|
|
struct nfs4_stid *stp;
|
|
|
|
|
2017-01-18 14:04:42 +03:00
|
|
|
stp = nfs4_alloc_stid(cstate->clp, nfs4_layout_stateid_cache,
|
|
|
|
nfsd4_free_layout_stateid);
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
if (!stp)
|
|
|
|
return NULL;
|
2017-01-18 14:04:42 +03:00
|
|
|
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
get_nfs4_file(fp);
|
|
|
|
stp->sc_file = fp;
|
|
|
|
|
|
|
|
ls = layoutstateid(stp);
|
|
|
|
INIT_LIST_HEAD(&ls->ls_perclnt);
|
|
|
|
INIT_LIST_HEAD(&ls->ls_perfile);
|
|
|
|
spin_lock_init(&ls->ls_lock);
|
|
|
|
INIT_LIST_HEAD(&ls->ls_layouts);
|
2015-09-17 14:58:24 +03:00
|
|
|
mutex_init(&ls->ls_mutex);
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
ls->ls_layout_type = layout_type;
|
2014-09-23 14:38:48 +04:00
|
|
|
nfsd4_init_cb(&ls->ls_recall, clp, &nfsd4_cb_layout_ops,
|
|
|
|
NFSPROC4_CLNT_CB_LAYOUT);
|
|
|
|
|
|
|
|
if (parent->sc_type == NFS4_DELEG_STID)
|
2019-08-18 21:18:53 +03:00
|
|
|
ls->ls_file = nfsd_file_get(fp->fi_deleg_file);
|
2014-09-23 14:38:48 +04:00
|
|
|
else
|
|
|
|
ls->ls_file = find_any_file(fp);
|
|
|
|
BUG_ON(!ls->ls_file);
|
|
|
|
|
|
|
|
if (nfsd4_layout_setlease(ls)) {
|
2019-08-18 21:18:53 +03:00
|
|
|
nfsd_file_put(ls->ls_file);
|
2014-09-23 14:38:48 +04:00
|
|
|
put_nfs4_file(fp);
|
|
|
|
kmem_cache_free(nfs4_layout_stateid_cache, ls);
|
|
|
|
return NULL;
|
|
|
|
}
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
|
|
|
|
spin_lock(&clp->cl_lock);
|
|
|
|
stp->sc_type = NFS4_LAYOUT_STID;
|
|
|
|
list_add(&ls->ls_perclnt, &clp->cl_lo_states);
|
|
|
|
spin_unlock(&clp->cl_lock);
|
|
|
|
|
|
|
|
spin_lock(&fp->fi_lock);
|
|
|
|
list_add(&ls->ls_perfile, &fp->fi_lo_states);
|
|
|
|
spin_unlock(&fp->fi_lock);
|
|
|
|
|
2018-03-27 17:53:11 +03:00
|
|
|
trace_nfsd_layoutstate_alloc(&ls->ls_stid.sc_stateid);
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
return ls;
|
|
|
|
}
|
|
|
|
|
|
|
|
__be32
|
|
|
|
nfsd4_preprocess_layout_stateid(struct svc_rqst *rqstp,
|
|
|
|
struct nfsd4_compound_state *cstate, stateid_t *stateid,
|
|
|
|
bool create, u32 layout_type, struct nfs4_layout_stateid **lsp)
|
|
|
|
{
|
|
|
|
struct nfs4_layout_stateid *ls;
|
|
|
|
struct nfs4_stid *stid;
|
|
|
|
unsigned char typemask = NFS4_LAYOUT_STID;
|
|
|
|
__be32 status;
|
|
|
|
|
|
|
|
if (create)
|
|
|
|
typemask |= (NFS4_OPEN_STID | NFS4_LOCK_STID | NFS4_DELEG_STID);
|
|
|
|
|
|
|
|
status = nfsd4_lookup_stateid(cstate, stateid, typemask, &stid,
|
|
|
|
net_generic(SVC_NET(rqstp), nfsd_net_id));
|
|
|
|
if (status)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (!fh_match(&cstate->current_fh.fh_handle,
|
|
|
|
&stid->sc_file->fi_fhandle)) {
|
|
|
|
status = nfserr_bad_stateid;
|
|
|
|
goto out_put_stid;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (stid->sc_type != NFS4_LAYOUT_STID) {
|
|
|
|
ls = nfsd4_alloc_layout_stateid(cstate, stid, layout_type);
|
|
|
|
nfs4_put_stid(stid);
|
|
|
|
|
|
|
|
status = nfserr_jukebox;
|
|
|
|
if (!ls)
|
|
|
|
goto out;
|
2015-09-17 14:58:24 +03:00
|
|
|
mutex_lock(&ls->ls_mutex);
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
} else {
|
|
|
|
ls = container_of(stid, struct nfs4_layout_stateid, ls_stid);
|
|
|
|
|
|
|
|
status = nfserr_bad_stateid;
|
2015-09-17 14:58:24 +03:00
|
|
|
mutex_lock(&ls->ls_mutex);
|
2016-05-05 13:53:47 +03:00
|
|
|
if (nfsd4_stateid_generation_after(stateid, &stid->sc_stateid))
|
2015-09-17 14:58:24 +03:00
|
|
|
goto out_unlock_stid;
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
if (layout_type != ls->ls_layout_type)
|
2015-09-17 14:58:24 +03:00
|
|
|
goto out_unlock_stid;
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
*lsp = ls;
|
|
|
|
return 0;
|
|
|
|
|
2015-09-17 14:58:24 +03:00
|
|
|
out_unlock_stid:
|
|
|
|
mutex_unlock(&ls->ls_mutex);
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
out_put_stid:
|
|
|
|
nfs4_put_stid(stid);
|
|
|
|
out:
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2014-09-23 14:38:48 +04:00
|
|
|
static void
|
|
|
|
nfsd4_recall_file_layout(struct nfs4_layout_stateid *ls)
|
|
|
|
{
|
|
|
|
spin_lock(&ls->ls_lock);
|
|
|
|
if (ls->ls_recalled)
|
|
|
|
goto out_unlock;
|
|
|
|
|
|
|
|
ls->ls_recalled = true;
|
|
|
|
atomic_inc(&ls->ls_stid.sc_file->fi_lo_recalls);
|
|
|
|
if (list_empty(&ls->ls_layouts))
|
|
|
|
goto out_unlock;
|
|
|
|
|
2018-03-27 17:53:11 +03:00
|
|
|
trace_nfsd_layout_recall(&ls->ls_stid.sc_stateid);
|
2014-08-17 04:02:22 +04:00
|
|
|
|
2017-10-20 12:53:28 +03:00
|
|
|
refcount_inc(&ls->ls_stid.sc_count);
|
2014-09-23 14:38:48 +04:00
|
|
|
nfsd4_run_cb(&ls->ls_recall);
|
|
|
|
|
|
|
|
out_unlock:
|
|
|
|
spin_unlock(&ls->ls_lock);
|
|
|
|
}
|
|
|
|
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
static inline u64
|
|
|
|
layout_end(struct nfsd4_layout_seg *seg)
|
|
|
|
{
|
|
|
|
u64 end = seg->offset + seg->length;
|
|
|
|
return end >= seg->offset ? end : NFS4_MAX_UINT64;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
layout_update_len(struct nfsd4_layout_seg *lo, u64 end)
|
|
|
|
{
|
|
|
|
if (end == NFS4_MAX_UINT64)
|
|
|
|
lo->length = NFS4_MAX_UINT64;
|
|
|
|
else
|
|
|
|
lo->length = end - lo->offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
layouts_overlapping(struct nfs4_layout *lo, struct nfsd4_layout_seg *s)
|
|
|
|
{
|
|
|
|
if (s->iomode != IOMODE_ANY && s->iomode != lo->lo_seg.iomode)
|
|
|
|
return false;
|
|
|
|
if (layout_end(&lo->lo_seg) <= s->offset)
|
|
|
|
return false;
|
|
|
|
if (layout_end(s) <= lo->lo_seg.offset)
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
layouts_try_merge(struct nfsd4_layout_seg *lo, struct nfsd4_layout_seg *new)
|
|
|
|
{
|
|
|
|
if (lo->iomode != new->iomode)
|
|
|
|
return false;
|
|
|
|
if (layout_end(new) < lo->offset)
|
|
|
|
return false;
|
|
|
|
if (layout_end(lo) < new->offset)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
lo->offset = min(lo->offset, new->offset);
|
|
|
|
layout_update_len(lo, max(layout_end(lo), layout_end(new)));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-09-23 14:38:48 +04:00
|
|
|
static __be32
|
|
|
|
nfsd4_recall_conflict(struct nfs4_layout_stateid *ls)
|
|
|
|
{
|
|
|
|
struct nfs4_file *fp = ls->ls_stid.sc_file;
|
|
|
|
struct nfs4_layout_stateid *l, *n;
|
|
|
|
__be32 nfserr = nfs_ok;
|
|
|
|
|
|
|
|
assert_spin_locked(&fp->fi_lock);
|
|
|
|
|
|
|
|
list_for_each_entry_safe(l, n, &fp->fi_lo_states, ls_perfile) {
|
|
|
|
if (l != ls) {
|
|
|
|
nfsd4_recall_file_layout(l);
|
|
|
|
nfserr = nfserr_recallconflict;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nfserr;
|
|
|
|
}
|
|
|
|
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
__be32
|
|
|
|
nfsd4_insert_layout(struct nfsd4_layoutget *lgp, struct nfs4_layout_stateid *ls)
|
|
|
|
{
|
|
|
|
struct nfsd4_layout_seg *seg = &lgp->lg_seg;
|
2014-09-23 14:38:48 +04:00
|
|
|
struct nfs4_file *fp = ls->ls_stid.sc_file;
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
struct nfs4_layout *lp, *new = NULL;
|
2014-09-23 14:38:48 +04:00
|
|
|
__be32 nfserr;
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
|
2014-09-23 14:38:48 +04:00
|
|
|
spin_lock(&fp->fi_lock);
|
|
|
|
nfserr = nfsd4_recall_conflict(ls);
|
|
|
|
if (nfserr)
|
|
|
|
goto out;
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
spin_lock(&ls->ls_lock);
|
|
|
|
list_for_each_entry(lp, &ls->ls_layouts, lo_perstate) {
|
|
|
|
if (layouts_try_merge(&lp->lo_seg, seg))
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
spin_unlock(&ls->ls_lock);
|
2014-09-23 14:38:48 +04:00
|
|
|
spin_unlock(&fp->fi_lock);
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
|
|
|
|
new = kmem_cache_alloc(nfs4_layout_cache, GFP_KERNEL);
|
|
|
|
if (!new)
|
|
|
|
return nfserr_jukebox;
|
|
|
|
memcpy(&new->lo_seg, seg, sizeof(lp->lo_seg));
|
|
|
|
new->lo_state = ls;
|
|
|
|
|
2014-09-23 14:38:48 +04:00
|
|
|
spin_lock(&fp->fi_lock);
|
|
|
|
nfserr = nfsd4_recall_conflict(ls);
|
|
|
|
if (nfserr)
|
|
|
|
goto out;
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
spin_lock(&ls->ls_lock);
|
|
|
|
list_for_each_entry(lp, &ls->ls_layouts, lo_perstate) {
|
|
|
|
if (layouts_try_merge(&lp->lo_seg, seg))
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2017-10-20 12:53:28 +03:00
|
|
|
refcount_inc(&ls->ls_stid.sc_count);
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
list_add_tail(&new->lo_perstate, &ls->ls_layouts);
|
|
|
|
new = NULL;
|
|
|
|
done:
|
2015-10-01 16:05:50 +03:00
|
|
|
nfs4_inc_and_copy_stateid(&lgp->lg_sid, &ls->ls_stid);
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
spin_unlock(&ls->ls_lock);
|
2014-09-23 14:38:48 +04:00
|
|
|
out:
|
|
|
|
spin_unlock(&fp->fi_lock);
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
if (new)
|
|
|
|
kmem_cache_free(nfs4_layout_cache, new);
|
2014-09-23 14:38:48 +04:00
|
|
|
return nfserr;
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
nfsd4_free_layouts(struct list_head *reaplist)
|
|
|
|
{
|
|
|
|
while (!list_empty(reaplist)) {
|
|
|
|
struct nfs4_layout *lp = list_first_entry(reaplist,
|
|
|
|
struct nfs4_layout, lo_perstate);
|
|
|
|
|
|
|
|
list_del(&lp->lo_perstate);
|
|
|
|
nfs4_put_stid(&lp->lo_state->ls_stid);
|
|
|
|
kmem_cache_free(nfs4_layout_cache, lp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
nfsd4_return_file_layout(struct nfs4_layout *lp, struct nfsd4_layout_seg *seg,
|
|
|
|
struct list_head *reaplist)
|
|
|
|
{
|
|
|
|
struct nfsd4_layout_seg *lo = &lp->lo_seg;
|
|
|
|
u64 end = layout_end(lo);
|
|
|
|
|
|
|
|
if (seg->offset <= lo->offset) {
|
|
|
|
if (layout_end(seg) >= end) {
|
|
|
|
list_move_tail(&lp->lo_perstate, reaplist);
|
|
|
|
return;
|
|
|
|
}
|
2015-03-22 17:17:20 +03:00
|
|
|
lo->offset = layout_end(seg);
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
} else {
|
|
|
|
/* retain the whole layout segment on a split. */
|
|
|
|
if (layout_end(seg) < end) {
|
|
|
|
dprintk("%s: split not supported\n", __func__);
|
|
|
|
return;
|
|
|
|
}
|
2015-03-22 17:17:20 +03:00
|
|
|
end = seg->offset;
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
layout_update_len(lo, end);
|
|
|
|
}
|
|
|
|
|
|
|
|
__be32
|
|
|
|
nfsd4_return_file_layouts(struct svc_rqst *rqstp,
|
|
|
|
struct nfsd4_compound_state *cstate,
|
|
|
|
struct nfsd4_layoutreturn *lrp)
|
|
|
|
{
|
|
|
|
struct nfs4_layout_stateid *ls;
|
|
|
|
struct nfs4_layout *lp, *n;
|
|
|
|
LIST_HEAD(reaplist);
|
|
|
|
__be32 nfserr;
|
|
|
|
int found = 0;
|
|
|
|
|
|
|
|
nfserr = nfsd4_preprocess_layout_stateid(rqstp, cstate, &lrp->lr_sid,
|
|
|
|
false, lrp->lr_layout_type,
|
|
|
|
&ls);
|
2014-08-17 04:02:22 +04:00
|
|
|
if (nfserr) {
|
2018-03-27 17:53:11 +03:00
|
|
|
trace_nfsd_layout_return_lookup_fail(&lrp->lr_sid);
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
return nfserr;
|
2014-08-17 04:02:22 +04:00
|
|
|
}
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
|
|
|
|
spin_lock(&ls->ls_lock);
|
|
|
|
list_for_each_entry_safe(lp, n, &ls->ls_layouts, lo_perstate) {
|
|
|
|
if (layouts_overlapping(lp, &lrp->lr_seg)) {
|
|
|
|
nfsd4_return_file_layout(lp, &lrp->lr_seg, &reaplist);
|
|
|
|
found++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!list_empty(&ls->ls_layouts)) {
|
2015-10-01 16:05:50 +03:00
|
|
|
if (found)
|
|
|
|
nfs4_inc_and_copy_stateid(&lrp->lr_sid, &ls->ls_stid);
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
lrp->lrs_present = 1;
|
|
|
|
} else {
|
2018-03-27 17:53:11 +03:00
|
|
|
trace_nfsd_layoutstate_unhash(&ls->ls_stid.sc_stateid);
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
nfs4_unhash_stid(&ls->ls_stid);
|
|
|
|
lrp->lrs_present = 0;
|
|
|
|
}
|
|
|
|
spin_unlock(&ls->ls_lock);
|
|
|
|
|
2015-09-17 14:58:24 +03:00
|
|
|
mutex_unlock(&ls->ls_mutex);
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
nfs4_put_stid(&ls->ls_stid);
|
|
|
|
nfsd4_free_layouts(&reaplist);
|
|
|
|
return nfs_ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
__be32
|
|
|
|
nfsd4_return_client_layouts(struct svc_rqst *rqstp,
|
|
|
|
struct nfsd4_compound_state *cstate,
|
|
|
|
struct nfsd4_layoutreturn *lrp)
|
|
|
|
{
|
|
|
|
struct nfs4_layout_stateid *ls, *n;
|
|
|
|
struct nfs4_client *clp = cstate->clp;
|
|
|
|
struct nfs4_layout *lp, *t;
|
|
|
|
LIST_HEAD(reaplist);
|
|
|
|
|
|
|
|
lrp->lrs_present = 0;
|
|
|
|
|
|
|
|
spin_lock(&clp->cl_lock);
|
|
|
|
list_for_each_entry_safe(ls, n, &clp->cl_lo_states, ls_perclnt) {
|
2015-03-19 14:04:14 +03:00
|
|
|
if (ls->ls_layout_type != lrp->lr_layout_type)
|
|
|
|
continue;
|
|
|
|
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
if (lrp->lr_return_type == RETURN_FSID &&
|
|
|
|
!fh_fsid_match(&ls->ls_stid.sc_file->fi_fhandle,
|
|
|
|
&cstate->current_fh.fh_handle))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
spin_lock(&ls->ls_lock);
|
|
|
|
list_for_each_entry_safe(lp, t, &ls->ls_layouts, lo_perstate) {
|
|
|
|
if (lrp->lr_seg.iomode == IOMODE_ANY ||
|
|
|
|
lrp->lr_seg.iomode == lp->lo_seg.iomode)
|
|
|
|
list_move_tail(&lp->lo_perstate, &reaplist);
|
|
|
|
}
|
|
|
|
spin_unlock(&ls->ls_lock);
|
|
|
|
}
|
|
|
|
spin_unlock(&clp->cl_lock);
|
|
|
|
|
|
|
|
nfsd4_free_layouts(&reaplist);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
nfsd4_return_all_layouts(struct nfs4_layout_stateid *ls,
|
|
|
|
struct list_head *reaplist)
|
|
|
|
{
|
|
|
|
spin_lock(&ls->ls_lock);
|
|
|
|
list_splice_init(&ls->ls_layouts, reaplist);
|
|
|
|
spin_unlock(&ls->ls_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nfsd4_return_all_client_layouts(struct nfs4_client *clp)
|
|
|
|
{
|
|
|
|
struct nfs4_layout_stateid *ls, *n;
|
|
|
|
LIST_HEAD(reaplist);
|
|
|
|
|
|
|
|
spin_lock(&clp->cl_lock);
|
|
|
|
list_for_each_entry_safe(ls, n, &clp->cl_lo_states, ls_perclnt)
|
|
|
|
nfsd4_return_all_layouts(ls, &reaplist);
|
|
|
|
spin_unlock(&clp->cl_lock);
|
|
|
|
|
|
|
|
nfsd4_free_layouts(&reaplist);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nfsd4_return_all_file_layouts(struct nfs4_client *clp, struct nfs4_file *fp)
|
|
|
|
{
|
|
|
|
struct nfs4_layout_stateid *ls, *n;
|
|
|
|
LIST_HEAD(reaplist);
|
|
|
|
|
|
|
|
spin_lock(&fp->fi_lock);
|
|
|
|
list_for_each_entry_safe(ls, n, &fp->fi_lo_states, ls_perfile) {
|
|
|
|
if (ls->ls_stid.sc_client == clp)
|
|
|
|
nfsd4_return_all_layouts(ls, &reaplist);
|
|
|
|
}
|
|
|
|
spin_unlock(&fp->fi_lock);
|
|
|
|
|
|
|
|
nfsd4_free_layouts(&reaplist);
|
|
|
|
}
|
|
|
|
|
2014-09-23 14:38:48 +04:00
|
|
|
static void
|
|
|
|
nfsd4_cb_layout_fail(struct nfs4_layout_stateid *ls)
|
|
|
|
{
|
|
|
|
struct nfs4_client *clp = ls->ls_stid.sc_client;
|
|
|
|
char addr_str[INET6_ADDRSTRLEN];
|
2016-12-11 20:00:43 +03:00
|
|
|
static char const nfsd_recall_failed[] = "/sbin/nfsd-recall-failed";
|
2014-09-23 14:38:48 +04:00
|
|
|
static char *envp[] = {
|
|
|
|
"HOME=/",
|
|
|
|
"TERM=linux",
|
|
|
|
"PATH=/sbin:/usr/sbin:/bin:/usr/bin",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
char *argv[8];
|
|
|
|
int error;
|
|
|
|
|
|
|
|
rpc_ntop((struct sockaddr *)&clp->cl_addr, addr_str, sizeof(addr_str));
|
|
|
|
|
|
|
|
printk(KERN_WARNING
|
|
|
|
"nfsd: client %s failed to respond to layout recall. "
|
|
|
|
" Fencing..\n", addr_str);
|
|
|
|
|
2016-12-11 20:00:43 +03:00
|
|
|
argv[0] = (char *)nfsd_recall_failed;
|
2014-09-23 14:38:48 +04:00
|
|
|
argv[1] = addr_str;
|
2019-08-18 21:18:53 +03:00
|
|
|
argv[2] = ls->ls_file->nf_file->f_path.mnt->mnt_sb->s_id;
|
2014-09-23 14:38:48 +04:00
|
|
|
argv[3] = NULL;
|
|
|
|
|
2016-12-11 20:00:43 +03:00
|
|
|
error = call_usermodehelper(nfsd_recall_failed, argv, envp,
|
|
|
|
UMH_WAIT_PROC);
|
2014-09-23 14:38:48 +04:00
|
|
|
if (error) {
|
|
|
|
printk(KERN_ERR "nfsd: fence failed for client %s: %d!\n",
|
|
|
|
addr_str, error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-17 14:58:24 +03:00
|
|
|
static void
|
|
|
|
nfsd4_cb_layout_prepare(struct nfsd4_callback *cb)
|
|
|
|
{
|
|
|
|
struct nfs4_layout_stateid *ls =
|
|
|
|
container_of(cb, struct nfs4_layout_stateid, ls_recall);
|
|
|
|
|
|
|
|
mutex_lock(&ls->ls_mutex);
|
2015-10-01 16:05:50 +03:00
|
|
|
nfs4_inc_and_copy_stateid(&ls->ls_recall_sid, &ls->ls_stid);
|
2015-11-29 16:46:14 +03:00
|
|
|
mutex_unlock(&ls->ls_mutex);
|
2015-09-17 14:58:24 +03:00
|
|
|
}
|
|
|
|
|
2014-09-23 14:38:48 +04:00
|
|
|
static int
|
|
|
|
nfsd4_cb_layout_done(struct nfsd4_callback *cb, struct rpc_task *task)
|
|
|
|
{
|
|
|
|
struct nfs4_layout_stateid *ls =
|
|
|
|
container_of(cb, struct nfs4_layout_stateid, ls_recall);
|
2015-12-08 15:23:48 +03:00
|
|
|
struct nfsd_net *nn;
|
|
|
|
ktime_t now, cutoff;
|
2016-03-04 22:46:17 +03:00
|
|
|
const struct nfsd4_layout_ops *ops;
|
2014-09-23 14:38:48 +04:00
|
|
|
|
2015-12-08 15:23:48 +03:00
|
|
|
|
2014-09-23 14:38:48 +04:00
|
|
|
switch (task->tk_status) {
|
|
|
|
case 0:
|
2015-12-08 15:23:48 +03:00
|
|
|
case -NFS4ERR_DELAY:
|
|
|
|
/*
|
|
|
|
* Anything left? If not, then call it done. Note that we don't
|
|
|
|
* take the spinlock since this is an optimization and nothing
|
|
|
|
* should get added until the cb counter goes to zero.
|
|
|
|
*/
|
|
|
|
if (list_empty(&ls->ls_layouts))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
/* Poll the client until it's done with the layout */
|
|
|
|
now = ktime_get();
|
|
|
|
nn = net_generic(ls->ls_stid.sc_client->net, nfsd_net_id);
|
|
|
|
|
|
|
|
/* Client gets 2 lease periods to return it */
|
|
|
|
cutoff = ktime_add_ns(task->tk_start,
|
|
|
|
nn->nfsd4_lease * NSEC_PER_SEC * 2);
|
|
|
|
|
|
|
|
if (ktime_before(now, cutoff)) {
|
|
|
|
rpc_delay(task, HZ/100); /* 10 mili-seconds */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* Fallthrough */
|
2014-09-23 14:38:48 +04:00
|
|
|
default:
|
|
|
|
/*
|
|
|
|
* Unknown error or non-responding client, we'll need to fence.
|
|
|
|
*/
|
2018-03-27 17:53:11 +03:00
|
|
|
trace_nfsd_layout_recall_fail(&ls->ls_stid.sc_stateid);
|
2016-03-04 22:46:17 +03:00
|
|
|
|
|
|
|
ops = nfsd4_layout_ops[ls->ls_layout_type];
|
|
|
|
if (ops->fence_client)
|
|
|
|
ops->fence_client(ls);
|
|
|
|
else
|
|
|
|
nfsd4_cb_layout_fail(ls);
|
2019-05-02 20:32:12 +03:00
|
|
|
return 1;
|
2016-10-20 19:21:34 +03:00
|
|
|
case -NFS4ERR_NOMATCHING_LAYOUT:
|
2018-03-27 17:53:11 +03:00
|
|
|
trace_nfsd_layout_recall_done(&ls->ls_stid.sc_stateid);
|
2016-10-20 19:21:34 +03:00
|
|
|
task->tk_status = 0;
|
|
|
|
return 1;
|
2014-09-23 14:38:48 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
nfsd4_cb_layout_release(struct nfsd4_callback *cb)
|
|
|
|
{
|
|
|
|
struct nfs4_layout_stateid *ls =
|
|
|
|
container_of(cb, struct nfs4_layout_stateid, ls_recall);
|
|
|
|
LIST_HEAD(reaplist);
|
|
|
|
|
2018-03-27 17:53:11 +03:00
|
|
|
trace_nfsd_layout_recall_release(&ls->ls_stid.sc_stateid);
|
2014-08-17 04:02:22 +04:00
|
|
|
|
2014-09-23 14:38:48 +04:00
|
|
|
nfsd4_return_all_layouts(ls, &reaplist);
|
|
|
|
nfsd4_free_layouts(&reaplist);
|
|
|
|
nfs4_put_stid(&ls->ls_stid);
|
|
|
|
}
|
|
|
|
|
2015-11-22 00:57:39 +03:00
|
|
|
static const struct nfsd4_callback_ops nfsd4_cb_layout_ops = {
|
2015-09-17 14:58:24 +03:00
|
|
|
.prepare = nfsd4_cb_layout_prepare,
|
2014-09-23 14:38:48 +04:00
|
|
|
.done = nfsd4_cb_layout_done,
|
|
|
|
.release = nfsd4_cb_layout_release,
|
|
|
|
};
|
|
|
|
|
|
|
|
static bool
|
|
|
|
nfsd4_layout_lm_break(struct file_lock *fl)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* We don't want the locks code to timeout the lease for us;
|
|
|
|
* we'll remove it ourself if a layout isn't returned
|
|
|
|
* in time:
|
|
|
|
*/
|
|
|
|
fl->fl_break_time = 0;
|
|
|
|
nfsd4_recall_file_layout(fl->fl_owner);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
nfsd4_layout_lm_change(struct file_lock *onlist, int arg,
|
|
|
|
struct list_head *dispose)
|
|
|
|
{
|
|
|
|
BUG_ON(!(arg & F_UNLCK));
|
|
|
|
return lease_modify(onlist, arg, dispose);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct lock_manager_operations nfsd4_layouts_lm_ops = {
|
|
|
|
.lm_break = nfsd4_layout_lm_break,
|
|
|
|
.lm_change = nfsd4_layout_lm_change,
|
|
|
|
};
|
|
|
|
|
nfsd: implement pNFS operations
Add support for the GETDEVICEINFO, LAYOUTGET, LAYOUTCOMMIT and
LAYOUTRETURN NFSv4.1 operations, as well as backing code to manage
outstanding layouts and devices.
Layout management is very straight forward, with a nfs4_layout_stateid
structure that extends nfs4_stid to manage layout stateids as the
top-level structure. It is linked into the nfs4_file and nfs4_client
structures like the other stateids, and contains a linked list of
layouts that hang of the stateid. The actual layout operations are
implemented in layout drivers that are not part of this commit, but
will be added later.
The worst part of this commit is the management of the pNFS device IDs,
which suffers from a specification that is not sanely implementable due
to the fact that the device-IDs are global and not bound to an export,
and have a small enough size so that we can't store the fsid portion of
a file handle, and must never be reused. As we still do need perform all
export authentication and validation checks on a device ID passed to
GETDEVICEINFO we are caught between a rock and a hard place. To work
around this issue we add a new hash that maps from a 64-bit integer to a
fsid so that we can look up the export to authenticate against it,
a 32-bit integer as a generation that we can bump when changing the device,
and a currently unused 32-bit integer that could be used in the future
to handle more than a single device per export. Entries in this hash
table are never deleted as we can't reuse the ids anyway, and would have
a severe lifetime problem anyway as Linux export structures are temporary
structures that can go away under load.
Parts of the XDR data, structures and marshaling/unmarshaling code, as
well as many concepts are derived from the old pNFS server implementation
from Andy Adamson, Benny Halevy, Dean Hildebrand, Marc Eshel, Fred Isaman,
Mike Sager, Ricardo Labiaga and many others.
Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-05 15:11:59 +04:00
|
|
|
int
|
|
|
|
nfsd4_init_pnfs(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < DEVID_HASH_SIZE; i++)
|
|
|
|
INIT_LIST_HEAD(&nfsd_devid_hash[i]);
|
|
|
|
|
|
|
|
nfs4_layout_cache = kmem_cache_create("nfs4_layout",
|
|
|
|
sizeof(struct nfs4_layout), 0, 0, NULL);
|
|
|
|
if (!nfs4_layout_cache)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
nfs4_layout_stateid_cache = kmem_cache_create("nfs4_layout_stateid",
|
|
|
|
sizeof(struct nfs4_layout_stateid), 0, 0, NULL);
|
|
|
|
if (!nfs4_layout_stateid_cache) {
|
|
|
|
kmem_cache_destroy(nfs4_layout_cache);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nfsd4_exit_pnfs(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
kmem_cache_destroy(nfs4_layout_cache);
|
|
|
|
kmem_cache_destroy(nfs4_layout_stateid_cache);
|
|
|
|
|
|
|
|
for (i = 0; i < DEVID_HASH_SIZE; i++) {
|
|
|
|
struct nfsd4_deviceid_map *map, *n;
|
|
|
|
|
|
|
|
list_for_each_entry_safe(map, n, &nfsd_devid_hash[i], hash)
|
|
|
|
kfree(map);
|
|
|
|
}
|
|
|
|
}
|