License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 22:07:57 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2010-04-07 06:14:15 +08:00
|
|
|
#include <linux/ceph/ceph_debug.h>
|
2009-10-07 02:31:11 +08:00
|
|
|
|
2010-04-07 06:14:15 +08:00
|
|
|
#include <linux/module.h>
|
2009-10-07 02:31:11 +08:00
|
|
|
#include <linux/types.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2009-10-07 02:31:11 +08:00
|
|
|
#include <linux/random.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
|
2017-06-05 20:45:00 +08:00
|
|
|
#include <linux/ceph/ceph_features.h>
|
2010-04-07 06:14:15 +08:00
|
|
|
#include <linux/ceph/mon_client.h>
|
|
|
|
#include <linux/ceph/libceph.h>
|
2012-01-14 14:22:03 +08:00
|
|
|
#include <linux/ceph/debugfs.h>
|
2010-04-07 06:14:15 +08:00
|
|
|
#include <linux/ceph/decode.h>
|
|
|
|
#include <linux/ceph/auth.h>
|
2009-10-07 02:31:11 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Interact with Ceph monitor cluster. Handle requests for new map
|
|
|
|
* versions, and periodically resend as needed. Also implement
|
|
|
|
* statfs() and umount().
|
|
|
|
*
|
|
|
|
* A small cluster of Ceph "monitors" are responsible for managing critical
|
|
|
|
* cluster configuration and state information. An odd number (e.g., 3, 5)
|
|
|
|
* of cmon daemons use a modified version of the Paxos part-time parliament
|
|
|
|
* algorithm to manage the MDS map (mds cluster membership), OSD map, and
|
|
|
|
* list of clients who have mounted the file system.
|
|
|
|
*
|
|
|
|
* We maintain an open, active session with a monitor at all times in order to
|
|
|
|
* receive timely MDSMap updates. We periodically send a keepalive byte on the
|
|
|
|
* TCP socket to ensure we detect a failure. If the connection does break, we
|
|
|
|
* randomly hunt for a new monitor. Once the connection is reestablished, we
|
|
|
|
* resend any outstanding requests.
|
|
|
|
*/
|
|
|
|
|
2010-05-20 16:40:19 +08:00
|
|
|
static const struct ceph_connection_operations mon_con_ops;
|
2009-10-07 02:31:11 +08:00
|
|
|
|
2010-02-03 08:21:06 +08:00
|
|
|
static int __validate_auth(struct ceph_mon_client *monc);
|
|
|
|
|
2009-10-07 02:31:11 +08:00
|
|
|
/*
|
|
|
|
* Decode a monmap blob (e.g., during mount).
|
|
|
|
*/
|
|
|
|
struct ceph_monmap *ceph_monmap_decode(void *p, void *end)
|
|
|
|
{
|
|
|
|
struct ceph_monmap *m = NULL;
|
|
|
|
int i, err = -EINVAL;
|
|
|
|
struct ceph_fsid fsid;
|
|
|
|
u32 epoch, num_mon;
|
2009-11-19 08:19:57 +08:00
|
|
|
u32 len;
|
|
|
|
|
|
|
|
ceph_decode_32_safe(&p, end, len, bad);
|
|
|
|
ceph_decode_need(&p, end, len, bad);
|
2009-10-07 02:31:11 +08:00
|
|
|
|
|
|
|
dout("monmap_decode %p %p len %d\n", p, end, (int)(end-p));
|
2017-05-19 17:59:22 +08:00
|
|
|
p += sizeof(u16); /* skip version */
|
2009-10-07 02:31:11 +08:00
|
|
|
|
|
|
|
ceph_decode_need(&p, end, sizeof(fsid) + 2*sizeof(u32), bad);
|
|
|
|
ceph_decode_copy(&p, &fsid, sizeof(fsid));
|
2009-10-15 00:59:09 +08:00
|
|
|
epoch = ceph_decode_32(&p);
|
2009-10-07 02:31:11 +08:00
|
|
|
|
2009-10-15 00:59:09 +08:00
|
|
|
num_mon = ceph_decode_32(&p);
|
2009-10-07 02:31:11 +08:00
|
|
|
ceph_decode_need(&p, end, num_mon*sizeof(m->mon_inst[0]), bad);
|
|
|
|
|
2018-02-11 09:33:28 +08:00
|
|
|
if (num_mon > CEPH_MAX_MON)
|
2009-10-07 02:31:11 +08:00
|
|
|
goto bad;
|
treewide: Use struct_size() for kmalloc()-family
One of the more common cases of allocation size calculations is finding
the size of a structure that has a zero-sized array at the end, along
with memory for some number of elements for that array. For example:
struct foo {
int stuff;
void *entry[];
};
instance = kmalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL);
Instead of leaving these open-coded and prone to type mistakes, we can
now use the new struct_size() helper:
instance = kmalloc(struct_size(instance, entry, count), GFP_KERNEL);
This patch makes the changes for kmalloc()-family (and kvmalloc()-family)
uses. It was done via automatic conversion with manual review for the
"CHECKME" non-standard cases noted below, using the following Coccinelle
script:
// pkey_cache = kmalloc(sizeof *pkey_cache + tprops->pkey_tbl_len *
// sizeof *pkey_cache->table, GFP_KERNEL);
@@
identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
expression GFP;
identifier VAR, ELEMENT;
expression COUNT;
@@
- alloc(sizeof(*VAR) + COUNT * sizeof(*VAR->ELEMENT), GFP)
+ alloc(struct_size(VAR, ELEMENT, COUNT), GFP)
// mr = kzalloc(sizeof(*mr) + m * sizeof(mr->map[0]), GFP_KERNEL);
@@
identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
expression GFP;
identifier VAR, ELEMENT;
expression COUNT;
@@
- alloc(sizeof(*VAR) + COUNT * sizeof(VAR->ELEMENT[0]), GFP)
+ alloc(struct_size(VAR, ELEMENT, COUNT), GFP)
// Same pattern, but can't trivially locate the trailing element name,
// or variable name.
@@
identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
expression GFP;
expression SOMETHING, COUNT, ELEMENT;
@@
- alloc(sizeof(SOMETHING) + COUNT * sizeof(ELEMENT), GFP)
+ alloc(CHECKME_struct_size(&SOMETHING, ELEMENT, COUNT), GFP)
Signed-off-by: Kees Cook <keescook@chromium.org>
2018-05-09 04:45:50 +08:00
|
|
|
m = kmalloc(struct_size(m, mon_inst, num_mon), GFP_NOFS);
|
2009-10-07 02:31:11 +08:00
|
|
|
if (m == NULL)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
m->fsid = fsid;
|
|
|
|
m->epoch = epoch;
|
|
|
|
m->num_mon = num_mon;
|
|
|
|
ceph_decode_copy(&p, m->mon_inst, num_mon*sizeof(m->mon_inst[0]));
|
2009-11-04 07:17:56 +08:00
|
|
|
for (i = 0; i < num_mon; i++)
|
|
|
|
ceph_decode_addr(&m->mon_inst[i].addr);
|
2009-10-07 02:31:11 +08:00
|
|
|
|
|
|
|
dout("monmap_decode epoch %d, num_mon %d\n", m->epoch,
|
|
|
|
m->num_mon);
|
|
|
|
for (i = 0; i < m->num_mon; i++)
|
|
|
|
dout("monmap_decode mon%d is %s\n", i,
|
2010-04-07 06:14:15 +08:00
|
|
|
ceph_pr_addr(&m->mon_inst[i].addr.in_addr));
|
2009-10-07 02:31:11 +08:00
|
|
|
return m;
|
|
|
|
|
|
|
|
bad:
|
|
|
|
dout("monmap_decode failed with %d\n", err);
|
|
|
|
kfree(m);
|
|
|
|
return ERR_PTR(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* return true if *addr is included in the monmap.
|
|
|
|
*/
|
|
|
|
int ceph_monmap_contains(struct ceph_monmap *m, struct ceph_entity_addr *addr)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < m->num_mon; i++)
|
2010-01-08 08:12:36 +08:00
|
|
|
if (memcmp(addr, &m->mon_inst[i].addr, sizeof(*addr)) == 0)
|
2009-10-07 02:31:11 +08:00
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-02-16 08:22:28 +08:00
|
|
|
/*
|
|
|
|
* Send an auth request.
|
|
|
|
*/
|
|
|
|
static void __send_prepared_auth_request(struct ceph_mon_client *monc, int len)
|
|
|
|
{
|
|
|
|
monc->pending_auth = 1;
|
|
|
|
monc->m_auth->front.iov_len = len;
|
|
|
|
monc->m_auth->hdr.front_len = cpu_to_le32(len);
|
2012-06-02 03:56:43 +08:00
|
|
|
ceph_msg_revoke(monc->m_auth);
|
2010-02-16 08:22:28 +08:00
|
|
|
ceph_msg_get(monc->m_auth); /* keep our ref */
|
2012-05-27 12:26:43 +08:00
|
|
|
ceph_con_send(&monc->con, monc->m_auth);
|
2010-02-16 08:22:28 +08:00
|
|
|
}
|
|
|
|
|
2009-10-07 02:31:11 +08:00
|
|
|
/*
|
|
|
|
* Close monitor session, if any.
|
|
|
|
*/
|
|
|
|
static void __close_session(struct ceph_mon_client *monc)
|
|
|
|
{
|
2011-08-10 00:27:44 +08:00
|
|
|
dout("__close_session closing mon%d\n", monc->cur_mon);
|
2012-06-02 03:56:43 +08:00
|
|
|
ceph_msg_revoke(monc->m_auth);
|
2012-07-31 09:16:40 +08:00
|
|
|
ceph_msg_revoke_incoming(monc->m_auth_reply);
|
|
|
|
ceph_msg_revoke(monc->m_subscribe);
|
|
|
|
ceph_msg_revoke_incoming(monc->m_subscribe_ack);
|
2012-05-27 12:26:43 +08:00
|
|
|
ceph_con_close(&monc->con);
|
2016-01-21 00:50:31 +08:00
|
|
|
|
2011-08-10 00:27:44 +08:00
|
|
|
monc->pending_auth = 0;
|
|
|
|
ceph_auth_reset(monc->auth);
|
2009-10-07 02:31:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2016-01-21 00:50:31 +08:00
|
|
|
* Pick a new monitor at random and set cur_mon. If we are repicking
|
|
|
|
* (i.e. cur_mon is already set), be sure to pick a different one.
|
2009-10-07 02:31:11 +08:00
|
|
|
*/
|
2016-01-21 00:50:31 +08:00
|
|
|
static void pick_new_mon(struct ceph_mon_client *monc)
|
2009-10-07 02:31:11 +08:00
|
|
|
{
|
2016-01-21 00:50:31 +08:00
|
|
|
int old_mon = monc->cur_mon;
|
2009-10-07 02:31:11 +08:00
|
|
|
|
2016-01-21 00:50:31 +08:00
|
|
|
BUG_ON(monc->monmap->num_mon < 1);
|
2009-10-07 02:31:11 +08:00
|
|
|
|
2016-01-21 00:50:31 +08:00
|
|
|
if (monc->monmap->num_mon == 1) {
|
|
|
|
monc->cur_mon = 0;
|
|
|
|
} else {
|
|
|
|
int max = monc->monmap->num_mon;
|
|
|
|
int o = -1;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
if (monc->cur_mon >= 0) {
|
|
|
|
if (monc->cur_mon < monc->monmap->num_mon)
|
|
|
|
o = monc->cur_mon;
|
|
|
|
if (o >= 0)
|
|
|
|
max--;
|
|
|
|
}
|
2009-11-19 08:19:57 +08:00
|
|
|
|
2016-01-21 00:50:31 +08:00
|
|
|
n = prandom_u32() % max;
|
|
|
|
if (o >= 0 && n >= o)
|
|
|
|
n++;
|
2015-09-01 17:19:38 +08:00
|
|
|
|
2016-01-21 00:50:31 +08:00
|
|
|
monc->cur_mon = n;
|
2009-10-07 02:31:11 +08:00
|
|
|
}
|
2016-01-21 00:50:31 +08:00
|
|
|
|
|
|
|
dout("%s mon%d -> mon%d out of %d mons\n", __func__, old_mon,
|
|
|
|
monc->cur_mon, monc->monmap->num_mon);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Open a session with a new monitor.
|
|
|
|
*/
|
|
|
|
static void __open_session(struct ceph_mon_client *monc)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
pick_new_mon(monc);
|
|
|
|
|
2016-01-21 23:33:25 +08:00
|
|
|
monc->hunting = true;
|
2016-01-21 23:33:19 +08:00
|
|
|
if (monc->had_a_connection) {
|
|
|
|
monc->hunt_mult *= CEPH_MONC_HUNT_BACKOFF;
|
|
|
|
if (monc->hunt_mult > CEPH_MONC_HUNT_MAX_MULT)
|
|
|
|
monc->hunt_mult = CEPH_MONC_HUNT_MAX_MULT;
|
|
|
|
}
|
|
|
|
|
2016-01-21 00:50:31 +08:00
|
|
|
monc->sub_renew_after = jiffies; /* i.e., expired */
|
|
|
|
monc->sub_renew_sent = 0;
|
|
|
|
|
|
|
|
dout("%s opening mon%d\n", __func__, monc->cur_mon);
|
|
|
|
ceph_con_open(&monc->con, CEPH_ENTITY_TYPE_MON, monc->cur_mon,
|
|
|
|
&monc->monmap->mon_inst[monc->cur_mon].addr);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* send an initial keepalive to ensure our timestamp is valid
|
|
|
|
* by the time we are in an OPENED state
|
|
|
|
*/
|
|
|
|
ceph_con_keepalive(&monc->con);
|
|
|
|
|
|
|
|
/* initiate authentication handshake */
|
|
|
|
ret = ceph_auth_build_hello(monc->auth,
|
|
|
|
monc->m_auth->front.iov_base,
|
|
|
|
monc->m_auth->front_alloc_len);
|
|
|
|
BUG_ON(ret <= 0);
|
|
|
|
__send_prepared_auth_request(monc, ret);
|
2009-10-07 02:31:11 +08:00
|
|
|
}
|
|
|
|
|
2016-01-21 23:33:25 +08:00
|
|
|
static void reopen_session(struct ceph_mon_client *monc)
|
|
|
|
{
|
|
|
|
if (!monc->hunting)
|
|
|
|
pr_info("mon%d %s session lost, hunting for new mon\n",
|
|
|
|
monc->cur_mon, ceph_pr_addr(&monc->con.peer_addr.in_addr));
|
|
|
|
|
|
|
|
__close_session(monc);
|
|
|
|
__open_session(monc);
|
|
|
|
}
|
|
|
|
|
2018-04-23 21:25:10 +08:00
|
|
|
static void un_backoff(struct ceph_mon_client *monc)
|
|
|
|
{
|
|
|
|
monc->hunt_mult /= 2; /* reduce by 50% */
|
|
|
|
if (monc->hunt_mult < 1)
|
|
|
|
monc->hunt_mult = 1;
|
|
|
|
dout("%s hunt_mult now %d\n", __func__, monc->hunt_mult);
|
|
|
|
}
|
|
|
|
|
2009-10-07 02:31:11 +08:00
|
|
|
/*
|
|
|
|
* Reschedule delayed work timer.
|
|
|
|
*/
|
|
|
|
static void __schedule_delayed(struct ceph_mon_client *monc)
|
|
|
|
{
|
2015-09-01 17:19:38 +08:00
|
|
|
unsigned long delay;
|
2009-10-07 02:31:11 +08:00
|
|
|
|
2016-01-21 23:33:19 +08:00
|
|
|
if (monc->hunting)
|
|
|
|
delay = CEPH_MONC_HUNT_INTERVAL * monc->hunt_mult;
|
|
|
|
else
|
2016-01-21 23:33:15 +08:00
|
|
|
delay = CEPH_MONC_PING_INTERVAL;
|
2016-01-21 23:33:19 +08:00
|
|
|
|
2015-09-01 17:19:38 +08:00
|
|
|
dout("__schedule_delayed after %lu\n", delay);
|
2016-01-23 01:42:17 +08:00
|
|
|
mod_delayed_work(system_wq, &monc->delayed_work,
|
|
|
|
round_jiffies_relative(delay));
|
2009-10-07 02:31:11 +08:00
|
|
|
}
|
|
|
|
|
2016-01-19 23:19:06 +08:00
|
|
|
const char *ceph_sub_str[] = {
|
|
|
|
[CEPH_SUB_MONMAP] = "monmap",
|
|
|
|
[CEPH_SUB_OSDMAP] = "osdmap",
|
2016-04-07 11:34:43 +08:00
|
|
|
[CEPH_SUB_FSMAP] = "fsmap.user",
|
|
|
|
[CEPH_SUB_MDSMAP] = "mdsmap",
|
2016-01-19 23:19:06 +08:00
|
|
|
};
|
|
|
|
|
2009-10-07 02:31:11 +08:00
|
|
|
/*
|
2016-01-19 23:19:06 +08:00
|
|
|
* Send subscribe request for one or more maps, according to
|
|
|
|
* monc->subs.
|
2009-10-07 02:31:11 +08:00
|
|
|
*/
|
|
|
|
static void __send_subscribe(struct ceph_mon_client *monc)
|
|
|
|
{
|
2016-01-19 23:19:06 +08:00
|
|
|
struct ceph_msg *msg = monc->m_subscribe;
|
|
|
|
void *p = msg->front.iov_base;
|
|
|
|
void *const end = p + msg->front_alloc_len;
|
|
|
|
int num = 0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
dout("%s sent %lu\n", __func__, monc->sub_renew_sent);
|
|
|
|
|
|
|
|
BUG_ON(monc->cur_mon < 0);
|
|
|
|
|
|
|
|
if (!monc->sub_renew_sent)
|
|
|
|
monc->sub_renew_sent = jiffies | 1; /* never 0 */
|
|
|
|
|
|
|
|
msg->hdr.version = cpu_to_le16(2);
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(monc->subs); i++) {
|
|
|
|
if (monc->subs[i].want)
|
|
|
|
num++;
|
|
|
|
}
|
|
|
|
BUG_ON(num < 1); /* monmap sub is always there */
|
|
|
|
ceph_encode_32(&p, num);
|
|
|
|
for (i = 0; i < ARRAY_SIZE(monc->subs); i++) {
|
2016-05-26 06:05:01 +08:00
|
|
|
char buf[32];
|
|
|
|
int len;
|
2016-01-19 23:19:06 +08:00
|
|
|
|
|
|
|
if (!monc->subs[i].want)
|
|
|
|
continue;
|
|
|
|
|
2016-05-26 06:05:01 +08:00
|
|
|
len = sprintf(buf, "%s", ceph_sub_str[i]);
|
|
|
|
if (i == CEPH_SUB_MDSMAP &&
|
|
|
|
monc->fs_cluster_id != CEPH_FS_CLUSTER_ID_NONE)
|
|
|
|
len += sprintf(buf + len, ".%d", monc->fs_cluster_id);
|
|
|
|
|
|
|
|
dout("%s %s start %llu flags 0x%x\n", __func__, buf,
|
2016-01-19 23:19:06 +08:00
|
|
|
le64_to_cpu(monc->subs[i].item.start),
|
|
|
|
monc->subs[i].item.flags);
|
2016-05-26 06:05:01 +08:00
|
|
|
ceph_encode_string(&p, end, buf, len);
|
2016-01-19 23:19:06 +08:00
|
|
|
memcpy(p, &monc->subs[i].item, sizeof(monc->subs[i].item));
|
|
|
|
p += sizeof(monc->subs[i].item);
|
2009-10-07 02:31:11 +08:00
|
|
|
}
|
2016-01-19 23:19:06 +08:00
|
|
|
|
2016-05-26 06:05:01 +08:00
|
|
|
BUG_ON(p > end);
|
2016-01-19 23:19:06 +08:00
|
|
|
msg->front.iov_len = p - msg->front.iov_base;
|
|
|
|
msg->hdr.front_len = cpu_to_le32(msg->front.iov_len);
|
|
|
|
ceph_msg_revoke(msg);
|
|
|
|
ceph_con_send(&monc->con, ceph_msg_get(msg));
|
2009-10-07 02:31:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void handle_subscribe_ack(struct ceph_mon_client *monc,
|
|
|
|
struct ceph_msg *msg)
|
|
|
|
{
|
2012-04-15 13:58:06 +08:00
|
|
|
unsigned int seconds;
|
2009-10-15 08:26:40 +08:00
|
|
|
struct ceph_mon_subscribe_ack *h = msg->front.iov_base;
|
|
|
|
|
|
|
|
if (msg->front.iov_len < sizeof(*h))
|
|
|
|
goto bad;
|
|
|
|
seconds = le32_to_cpu(h->duration);
|
2009-10-07 02:31:11 +08:00
|
|
|
|
|
|
|
mutex_lock(&monc->mutex);
|
2016-01-19 23:19:06 +08:00
|
|
|
if (monc->sub_renew_sent) {
|
2017-06-05 20:45:00 +08:00
|
|
|
/*
|
|
|
|
* This is only needed for legacy (infernalis or older)
|
|
|
|
* MONs -- see delayed_work().
|
|
|
|
*/
|
2016-01-19 23:19:06 +08:00
|
|
|
monc->sub_renew_after = monc->sub_renew_sent +
|
|
|
|
(seconds >> 1) * HZ - 1;
|
|
|
|
dout("%s sent %lu duration %d renew after %lu\n", __func__,
|
|
|
|
monc->sub_renew_sent, seconds, monc->sub_renew_after);
|
|
|
|
monc->sub_renew_sent = 0;
|
|
|
|
} else {
|
|
|
|
dout("%s sent %lu renew after %lu, ignoring\n", __func__,
|
|
|
|
monc->sub_renew_sent, monc->sub_renew_after);
|
|
|
|
}
|
2009-10-07 02:31:11 +08:00
|
|
|
mutex_unlock(&monc->mutex);
|
|
|
|
return;
|
|
|
|
bad:
|
|
|
|
pr_err("got corrupt subscribe-ack msg\n");
|
2009-12-15 07:13:47 +08:00
|
|
|
ceph_msg_dump(msg);
|
2009-10-07 02:31:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2016-01-19 23:19:06 +08:00
|
|
|
* Register interest in a map
|
|
|
|
*
|
|
|
|
* @sub: one of CEPH_SUB_*
|
|
|
|
* @epoch: X for "every map since X", or 0 for "just the latest"
|
2009-10-07 02:31:11 +08:00
|
|
|
*/
|
2016-01-19 23:19:06 +08:00
|
|
|
static bool __ceph_monc_want_map(struct ceph_mon_client *monc, int sub,
|
|
|
|
u32 epoch, bool continuous)
|
2009-10-07 02:31:11 +08:00
|
|
|
{
|
2016-01-19 23:19:06 +08:00
|
|
|
__le64 start = cpu_to_le64(epoch);
|
|
|
|
u8 flags = !continuous ? CEPH_SUBSCRIBE_ONETIME : 0;
|
|
|
|
|
|
|
|
dout("%s %s epoch %u continuous %d\n", __func__, ceph_sub_str[sub],
|
|
|
|
epoch, continuous);
|
|
|
|
|
|
|
|
if (monc->subs[sub].want &&
|
|
|
|
monc->subs[sub].item.start == start &&
|
|
|
|
monc->subs[sub].item.flags == flags)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
monc->subs[sub].item.start = start;
|
|
|
|
monc->subs[sub].item.flags = flags;
|
|
|
|
monc->subs[sub].want = true;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ceph_monc_want_map(struct ceph_mon_client *monc, int sub, u32 epoch,
|
|
|
|
bool continuous)
|
|
|
|
{
|
|
|
|
bool need_request;
|
|
|
|
|
2009-10-07 02:31:11 +08:00
|
|
|
mutex_lock(&monc->mutex);
|
2016-01-19 23:19:06 +08:00
|
|
|
need_request = __ceph_monc_want_map(monc, sub, epoch, continuous);
|
2009-10-07 02:31:11 +08:00
|
|
|
mutex_unlock(&monc->mutex);
|
2016-01-19 23:19:06 +08:00
|
|
|
|
|
|
|
return need_request;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(ceph_monc_want_map);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Keep track of which maps we have
|
|
|
|
*
|
|
|
|
* @sub: one of CEPH_SUB_*
|
|
|
|
*/
|
|
|
|
static void __ceph_monc_got_map(struct ceph_mon_client *monc, int sub,
|
|
|
|
u32 epoch)
|
|
|
|
{
|
|
|
|
dout("%s %s epoch %u\n", __func__, ceph_sub_str[sub], epoch);
|
|
|
|
|
|
|
|
if (monc->subs[sub].want) {
|
|
|
|
if (monc->subs[sub].item.flags & CEPH_SUBSCRIBE_ONETIME)
|
|
|
|
monc->subs[sub].want = false;
|
|
|
|
else
|
|
|
|
monc->subs[sub].item.start = cpu_to_le64(epoch + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
monc->subs[sub].have = epoch;
|
2009-10-07 02:31:11 +08:00
|
|
|
}
|
|
|
|
|
2016-01-19 23:19:06 +08:00
|
|
|
void ceph_monc_got_map(struct ceph_mon_client *monc, int sub, u32 epoch)
|
2009-10-07 02:31:11 +08:00
|
|
|
{
|
|
|
|
mutex_lock(&monc->mutex);
|
2016-01-19 23:19:06 +08:00
|
|
|
__ceph_monc_got_map(monc, sub, epoch);
|
2009-10-07 02:31:11 +08:00
|
|
|
mutex_unlock(&monc->mutex);
|
|
|
|
}
|
2016-01-19 23:19:06 +08:00
|
|
|
EXPORT_SYMBOL(ceph_monc_got_map);
|
2009-10-07 02:31:11 +08:00
|
|
|
|
2016-04-28 22:07:25 +08:00
|
|
|
void ceph_monc_renew_subs(struct ceph_mon_client *monc)
|
|
|
|
{
|
|
|
|
mutex_lock(&monc->mutex);
|
|
|
|
__send_subscribe(monc);
|
|
|
|
mutex_unlock(&monc->mutex);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(ceph_monc_renew_subs);
|
|
|
|
|
2015-05-15 17:02:17 +08:00
|
|
|
/*
|
|
|
|
* Wait for an osdmap with a given epoch.
|
|
|
|
*
|
|
|
|
* @epoch: epoch to wait for
|
|
|
|
* @timeout: in jiffies, 0 means "wait forever"
|
|
|
|
*/
|
2014-05-13 15:19:27 +08:00
|
|
|
int ceph_monc_wait_osdmap(struct ceph_mon_client *monc, u32 epoch,
|
|
|
|
unsigned long timeout)
|
|
|
|
{
|
|
|
|
unsigned long started = jiffies;
|
2015-05-19 17:03:33 +08:00
|
|
|
long ret;
|
2014-05-13 15:19:27 +08:00
|
|
|
|
|
|
|
mutex_lock(&monc->mutex);
|
2016-01-19 23:19:06 +08:00
|
|
|
while (monc->subs[CEPH_SUB_OSDMAP].have < epoch) {
|
2014-05-13 15:19:27 +08:00
|
|
|
mutex_unlock(&monc->mutex);
|
|
|
|
|
2015-05-15 17:02:17 +08:00
|
|
|
if (timeout && time_after_eq(jiffies, started + timeout))
|
2014-05-13 15:19:27 +08:00
|
|
|
return -ETIMEDOUT;
|
|
|
|
|
|
|
|
ret = wait_event_interruptible_timeout(monc->client->auth_wq,
|
2016-01-19 23:19:06 +08:00
|
|
|
monc->subs[CEPH_SUB_OSDMAP].have >= epoch,
|
|
|
|
ceph_timeout_jiffies(timeout));
|
2014-05-13 15:19:27 +08:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
mutex_lock(&monc->mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
mutex_unlock(&monc->mutex);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(ceph_monc_wait_osdmap);
|
2009-10-07 02:31:11 +08:00
|
|
|
|
2009-11-19 08:19:57 +08:00
|
|
|
/*
|
2016-01-19 23:19:06 +08:00
|
|
|
* Open a session with a random monitor. Request monmap and osdmap,
|
|
|
|
* which are waited upon in __ceph_open_session().
|
2009-11-19 08:19:57 +08:00
|
|
|
*/
|
|
|
|
int ceph_monc_open_session(struct ceph_mon_client *monc)
|
2009-10-07 02:31:11 +08:00
|
|
|
{
|
|
|
|
mutex_lock(&monc->mutex);
|
2016-01-19 23:19:06 +08:00
|
|
|
__ceph_monc_want_map(monc, CEPH_SUB_MONMAP, 0, true);
|
|
|
|
__ceph_monc_want_map(monc, CEPH_SUB_OSDMAP, 0, false);
|
2009-11-19 08:19:57 +08:00
|
|
|
__open_session(monc);
|
2009-10-07 02:31:11 +08:00
|
|
|
__schedule_delayed(monc);
|
|
|
|
mutex_unlock(&monc->mutex);
|
|
|
|
return 0;
|
|
|
|
}
|
2010-04-07 06:14:15 +08:00
|
|
|
EXPORT_SYMBOL(ceph_monc_open_session);
|
2009-10-07 02:31:11 +08:00
|
|
|
|
2009-11-19 08:50:41 +08:00
|
|
|
static void ceph_monc_handle_map(struct ceph_mon_client *monc,
|
|
|
|
struct ceph_msg *msg)
|
2009-11-19 08:19:57 +08:00
|
|
|
{
|
|
|
|
struct ceph_client *client = monc->client;
|
|
|
|
struct ceph_monmap *monmap = NULL, *old = monc->monmap;
|
|
|
|
void *p, *end;
|
|
|
|
|
|
|
|
mutex_lock(&monc->mutex);
|
|
|
|
|
|
|
|
dout("handle_monmap\n");
|
|
|
|
p = msg->front.iov_base;
|
|
|
|
end = p + msg->front.iov_len;
|
|
|
|
|
|
|
|
monmap = ceph_monmap_decode(p, end);
|
|
|
|
if (IS_ERR(monmap)) {
|
|
|
|
pr_err("problem decoding monmap, %d\n",
|
|
|
|
(int)PTR_ERR(monmap));
|
2009-12-12 00:55:23 +08:00
|
|
|
goto out;
|
2009-11-19 08:19:57 +08:00
|
|
|
}
|
2009-11-19 08:50:41 +08:00
|
|
|
|
|
|
|
if (ceph_check_fsid(monc->client, &monmap->fsid) < 0) {
|
2009-11-19 08:19:57 +08:00
|
|
|
kfree(monmap);
|
2009-12-12 00:55:23 +08:00
|
|
|
goto out;
|
2009-11-19 08:19:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
client->monc.monmap = monmap;
|
|
|
|
kfree(old);
|
|
|
|
|
2016-01-19 23:19:06 +08:00
|
|
|
__ceph_monc_got_map(monc, CEPH_SUB_MONMAP, monc->monmap->epoch);
|
2016-01-06 17:56:21 +08:00
|
|
|
client->have_fsid = true;
|
2012-08-20 03:29:16 +08:00
|
|
|
|
2009-12-12 00:55:23 +08:00
|
|
|
out:
|
2009-11-19 08:19:57 +08:00
|
|
|
mutex_unlock(&monc->mutex);
|
2010-07-28 04:11:08 +08:00
|
|
|
wake_up_all(&client->auth_wq);
|
2009-11-19 08:19:57 +08:00
|
|
|
}
|
|
|
|
|
2009-10-07 02:31:11 +08:00
|
|
|
/*
|
2014-12-23 00:14:26 +08:00
|
|
|
* generic requests (currently statfs, mon_get_version)
|
2009-10-07 02:31:11 +08:00
|
|
|
*/
|
2016-04-28 22:07:22 +08:00
|
|
|
DEFINE_RB_FUNCS(generic_request, struct ceph_mon_generic_request, tid, node)
|
2010-02-16 06:47:28 +08:00
|
|
|
|
2010-04-23 06:40:37 +08:00
|
|
|
static void release_generic_request(struct kref *kref)
|
2010-03-25 12:43:33 +08:00
|
|
|
{
|
2010-04-23 06:40:37 +08:00
|
|
|
struct ceph_mon_generic_request *req =
|
|
|
|
container_of(kref, struct ceph_mon_generic_request, kref);
|
2010-03-25 12:43:33 +08:00
|
|
|
|
2016-04-28 22:07:27 +08:00
|
|
|
dout("%s greq %p request %p reply %p\n", __func__, req, req->request,
|
|
|
|
req->reply);
|
|
|
|
WARN_ON(!RB_EMPTY_NODE(&req->node));
|
|
|
|
|
2010-03-25 12:43:33 +08:00
|
|
|
if (req->reply)
|
|
|
|
ceph_msg_put(req->reply);
|
|
|
|
if (req->request)
|
|
|
|
ceph_msg_put(req->request);
|
2010-06-02 01:37:40 +08:00
|
|
|
|
|
|
|
kfree(req);
|
2010-03-25 12:43:33 +08:00
|
|
|
}
|
|
|
|
|
2010-04-23 06:40:37 +08:00
|
|
|
static void put_generic_request(struct ceph_mon_generic_request *req)
|
2010-03-25 12:43:33 +08:00
|
|
|
{
|
2016-04-28 22:07:27 +08:00
|
|
|
if (req)
|
|
|
|
kref_put(&req->kref, release_generic_request);
|
2010-03-25 12:43:33 +08:00
|
|
|
}
|
|
|
|
|
2010-04-23 06:40:37 +08:00
|
|
|
static void get_generic_request(struct ceph_mon_generic_request *req)
|
2010-03-25 12:43:33 +08:00
|
|
|
{
|
|
|
|
kref_get(&req->kref);
|
|
|
|
}
|
|
|
|
|
2016-04-28 22:07:27 +08:00
|
|
|
static struct ceph_mon_generic_request *
|
|
|
|
alloc_generic_request(struct ceph_mon_client *monc, gfp_t gfp)
|
|
|
|
{
|
|
|
|
struct ceph_mon_generic_request *req;
|
|
|
|
|
|
|
|
req = kzalloc(sizeof(*req), gfp);
|
|
|
|
if (!req)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
req->monc = monc;
|
|
|
|
kref_init(&req->kref);
|
|
|
|
RB_CLEAR_NODE(&req->node);
|
|
|
|
init_completion(&req->completion);
|
|
|
|
|
|
|
|
dout("%s greq %p\n", __func__, req);
|
|
|
|
return req;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void register_generic_request(struct ceph_mon_generic_request *req)
|
|
|
|
{
|
|
|
|
struct ceph_mon_client *monc = req->monc;
|
|
|
|
|
|
|
|
WARN_ON(req->tid);
|
|
|
|
|
|
|
|
get_generic_request(req);
|
|
|
|
req->tid = ++monc->last_tid;
|
|
|
|
insert_generic_request(&monc->generic_request_tree, req);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void send_generic_request(struct ceph_mon_client *monc,
|
|
|
|
struct ceph_mon_generic_request *req)
|
|
|
|
{
|
|
|
|
WARN_ON(!req->tid);
|
|
|
|
|
|
|
|
dout("%s greq %p tid %llu\n", __func__, req, req->tid);
|
|
|
|
req->request->hdr.tid = cpu_to_le64(req->tid);
|
|
|
|
ceph_con_send(&monc->con, ceph_msg_get(req->request));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __finish_generic_request(struct ceph_mon_generic_request *req)
|
|
|
|
{
|
|
|
|
struct ceph_mon_client *monc = req->monc;
|
|
|
|
|
|
|
|
dout("%s greq %p tid %llu\n", __func__, req, req->tid);
|
|
|
|
erase_generic_request(&monc->generic_request_tree, req);
|
|
|
|
|
|
|
|
ceph_msg_revoke(req->request);
|
|
|
|
ceph_msg_revoke_incoming(req->reply);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void finish_generic_request(struct ceph_mon_generic_request *req)
|
|
|
|
{
|
|
|
|
__finish_generic_request(req);
|
|
|
|
put_generic_request(req);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void complete_generic_request(struct ceph_mon_generic_request *req)
|
|
|
|
{
|
|
|
|
if (req->complete_cb)
|
|
|
|
req->complete_cb(req);
|
|
|
|
else
|
|
|
|
complete_all(&req->completion);
|
|
|
|
put_generic_request(req);
|
|
|
|
}
|
|
|
|
|
2016-07-30 08:37:31 +08:00
|
|
|
static void cancel_generic_request(struct ceph_mon_generic_request *req)
|
2016-04-28 22:07:27 +08:00
|
|
|
{
|
|
|
|
struct ceph_mon_client *monc = req->monc;
|
|
|
|
struct ceph_mon_generic_request *lookup_req;
|
|
|
|
|
|
|
|
dout("%s greq %p tid %llu\n", __func__, req, req->tid);
|
|
|
|
|
|
|
|
mutex_lock(&monc->mutex);
|
|
|
|
lookup_req = lookup_generic_request(&monc->generic_request_tree,
|
|
|
|
req->tid);
|
|
|
|
if (lookup_req) {
|
|
|
|
WARN_ON(lookup_req != req);
|
|
|
|
finish_generic_request(req);
|
|
|
|
}
|
|
|
|
|
|
|
|
mutex_unlock(&monc->mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wait_generic_request(struct ceph_mon_generic_request *req)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
dout("%s greq %p tid %llu\n", __func__, req, req->tid);
|
|
|
|
ret = wait_for_completion_interruptible(&req->completion);
|
|
|
|
if (ret)
|
|
|
|
cancel_generic_request(req);
|
|
|
|
else
|
|
|
|
ret = req->result; /* completed */
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-04-23 06:40:37 +08:00
|
|
|
static struct ceph_msg *get_generic_reply(struct ceph_connection *con,
|
2010-03-25 12:43:33 +08:00
|
|
|
struct ceph_msg_header *hdr,
|
|
|
|
int *skip)
|
|
|
|
{
|
|
|
|
struct ceph_mon_client *monc = con->private;
|
2010-04-23 06:40:37 +08:00
|
|
|
struct ceph_mon_generic_request *req;
|
2010-03-25 12:43:33 +08:00
|
|
|
u64 tid = le64_to_cpu(hdr->tid);
|
|
|
|
struct ceph_msg *m;
|
|
|
|
|
|
|
|
mutex_lock(&monc->mutex);
|
2016-04-28 22:07:22 +08:00
|
|
|
req = lookup_generic_request(&monc->generic_request_tree, tid);
|
2010-03-25 12:43:33 +08:00
|
|
|
if (!req) {
|
2010-04-23 06:40:37 +08:00
|
|
|
dout("get_generic_reply %lld dne\n", tid);
|
2010-03-25 12:43:33 +08:00
|
|
|
*skip = 1;
|
|
|
|
m = NULL;
|
|
|
|
} else {
|
2010-04-23 06:40:37 +08:00
|
|
|
dout("get_generic_reply %lld got %p\n", tid, req->reply);
|
2012-06-05 03:43:32 +08:00
|
|
|
*skip = 0;
|
2010-03-25 12:43:33 +08:00
|
|
|
m = ceph_msg_get(req->reply);
|
|
|
|
/*
|
|
|
|
* we don't need to track the connection reading into
|
|
|
|
* this reply because we only have one open connection
|
|
|
|
* at a time, ever.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
mutex_unlock(&monc->mutex);
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
2010-05-18 03:40:28 +08:00
|
|
|
/*
|
|
|
|
* statfs
|
|
|
|
*/
|
2009-10-07 02:31:11 +08:00
|
|
|
static void handle_statfs_reply(struct ceph_mon_client *monc,
|
|
|
|
struct ceph_msg *msg)
|
|
|
|
{
|
2010-04-23 06:40:37 +08:00
|
|
|
struct ceph_mon_generic_request *req;
|
2009-10-07 02:31:11 +08:00
|
|
|
struct ceph_mon_statfs_reply *reply = msg->front.iov_base;
|
2010-03-25 12:43:33 +08:00
|
|
|
u64 tid = le64_to_cpu(msg->hdr.tid);
|
2009-10-07 02:31:11 +08:00
|
|
|
|
2016-04-28 22:07:27 +08:00
|
|
|
dout("%s msg %p tid %llu\n", __func__, msg, tid);
|
|
|
|
|
2009-10-07 02:31:11 +08:00
|
|
|
if (msg->front.iov_len != sizeof(*reply))
|
|
|
|
goto bad;
|
|
|
|
|
|
|
|
mutex_lock(&monc->mutex);
|
2016-04-28 22:07:22 +08:00
|
|
|
req = lookup_generic_request(&monc->generic_request_tree, tid);
|
2016-04-28 22:07:27 +08:00
|
|
|
if (!req) {
|
|
|
|
mutex_unlock(&monc->mutex);
|
|
|
|
return;
|
2009-10-07 02:31:11 +08:00
|
|
|
}
|
2016-04-28 22:07:27 +08:00
|
|
|
|
|
|
|
req->result = 0;
|
|
|
|
*req->u.st = reply->st; /* struct */
|
|
|
|
__finish_generic_request(req);
|
2009-10-07 02:31:11 +08:00
|
|
|
mutex_unlock(&monc->mutex);
|
2016-04-28 22:07:27 +08:00
|
|
|
|
|
|
|
complete_generic_request(req);
|
2009-10-07 02:31:11 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
bad:
|
2014-12-23 00:14:26 +08:00
|
|
|
pr_err("corrupt statfs reply, tid %llu\n", tid);
|
2009-12-15 07:13:47 +08:00
|
|
|
ceph_msg_dump(msg);
|
2009-10-07 02:31:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2010-03-25 12:43:33 +08:00
|
|
|
* Do a synchronous statfs().
|
2009-10-07 02:31:11 +08:00
|
|
|
*/
|
2017-08-16 22:19:27 +08:00
|
|
|
int ceph_monc_do_statfs(struct ceph_mon_client *monc, u64 data_pool,
|
|
|
|
struct ceph_statfs *buf)
|
2009-10-07 02:31:11 +08:00
|
|
|
{
|
2010-04-23 06:40:37 +08:00
|
|
|
struct ceph_mon_generic_request *req;
|
2009-10-07 02:31:11 +08:00
|
|
|
struct ceph_mon_statfs *h;
|
2016-04-28 22:07:27 +08:00
|
|
|
int ret = -ENOMEM;
|
2010-03-25 12:43:33 +08:00
|
|
|
|
2016-04-28 22:07:27 +08:00
|
|
|
req = alloc_generic_request(monc, GFP_NOFS);
|
2010-03-25 12:43:33 +08:00
|
|
|
if (!req)
|
2016-04-28 22:07:27 +08:00
|
|
|
goto out;
|
2009-10-07 02:31:11 +08:00
|
|
|
|
2011-08-10 06:03:46 +08:00
|
|
|
req->request = ceph_msg_new(CEPH_MSG_STATFS, sizeof(*h), GFP_NOFS,
|
|
|
|
true);
|
2010-04-02 07:06:19 +08:00
|
|
|
if (!req->request)
|
2010-03-25 12:43:33 +08:00
|
|
|
goto out;
|
2016-04-28 22:07:27 +08:00
|
|
|
|
|
|
|
req->reply = ceph_msg_new(CEPH_MSG_STATFS_REPLY, 64, GFP_NOFS, true);
|
2010-04-02 07:06:19 +08:00
|
|
|
if (!req->reply)
|
2010-03-25 12:43:33 +08:00
|
|
|
goto out;
|
|
|
|
|
2016-04-28 22:07:27 +08:00
|
|
|
req->u.st = buf;
|
2017-08-16 22:19:27 +08:00
|
|
|
req->request->hdr.version = cpu_to_le16(2);
|
2016-04-28 22:07:27 +08:00
|
|
|
|
|
|
|
mutex_lock(&monc->mutex);
|
|
|
|
register_generic_request(req);
|
2010-03-25 12:43:33 +08:00
|
|
|
/* fill out request */
|
|
|
|
h = req->request->front.iov_base;
|
2009-10-10 07:36:34 +08:00
|
|
|
h->monhdr.have_version = 0;
|
|
|
|
h->monhdr.session_mon = cpu_to_le16(-1);
|
|
|
|
h->monhdr.session_mon_tid = 0;
|
2009-10-07 02:31:11 +08:00
|
|
|
h->fsid = monc->monmap->fsid;
|
2017-08-16 22:19:27 +08:00
|
|
|
h->contains_data_pool = (data_pool != CEPH_NOPOOL);
|
|
|
|
h->data_pool = cpu_to_le64(data_pool);
|
2016-04-28 22:07:27 +08:00
|
|
|
send_generic_request(monc, req);
|
|
|
|
mutex_unlock(&monc->mutex);
|
2009-10-07 02:31:11 +08:00
|
|
|
|
2016-04-28 22:07:27 +08:00
|
|
|
ret = wait_generic_request(req);
|
2010-05-18 03:40:28 +08:00
|
|
|
out:
|
2014-12-23 00:35:17 +08:00
|
|
|
put_generic_request(req);
|
2016-04-28 22:07:27 +08:00
|
|
|
return ret;
|
2010-05-18 03:40:28 +08:00
|
|
|
}
|
2010-04-07 06:14:15 +08:00
|
|
|
EXPORT_SYMBOL(ceph_monc_do_statfs);
|
2010-05-18 03:40:28 +08:00
|
|
|
|
2014-05-13 15:19:26 +08:00
|
|
|
static void handle_get_version_reply(struct ceph_mon_client *monc,
|
|
|
|
struct ceph_msg *msg)
|
|
|
|
{
|
|
|
|
struct ceph_mon_generic_request *req;
|
|
|
|
u64 tid = le64_to_cpu(msg->hdr.tid);
|
|
|
|
void *p = msg->front.iov_base;
|
|
|
|
void *end = p + msg->front_alloc_len;
|
|
|
|
u64 handle;
|
|
|
|
|
2016-04-28 22:07:27 +08:00
|
|
|
dout("%s msg %p tid %llu\n", __func__, msg, tid);
|
2014-05-13 15:19:26 +08:00
|
|
|
|
|
|
|
ceph_decode_need(&p, end, 2*sizeof(u64), bad);
|
|
|
|
handle = ceph_decode_64(&p);
|
|
|
|
if (tid != 0 && tid != handle)
|
|
|
|
goto bad;
|
|
|
|
|
|
|
|
mutex_lock(&monc->mutex);
|
2016-04-28 22:07:22 +08:00
|
|
|
req = lookup_generic_request(&monc->generic_request_tree, handle);
|
2016-04-28 22:07:27 +08:00
|
|
|
if (!req) {
|
|
|
|
mutex_unlock(&monc->mutex);
|
|
|
|
return;
|
2014-05-13 15:19:26 +08:00
|
|
|
}
|
2016-04-28 22:07:27 +08:00
|
|
|
|
|
|
|
req->result = 0;
|
|
|
|
req->u.newest = ceph_decode_64(&p);
|
|
|
|
__finish_generic_request(req);
|
2014-05-13 15:19:26 +08:00
|
|
|
mutex_unlock(&monc->mutex);
|
|
|
|
|
2016-04-28 22:07:27 +08:00
|
|
|
complete_generic_request(req);
|
2014-05-13 15:19:26 +08:00
|
|
|
return;
|
2016-04-28 22:07:27 +08:00
|
|
|
|
2014-05-13 15:19:26 +08:00
|
|
|
bad:
|
2014-12-23 00:14:26 +08:00
|
|
|
pr_err("corrupt mon_get_version reply, tid %llu\n", tid);
|
2014-05-13 15:19:26 +08:00
|
|
|
ceph_msg_dump(msg);
|
|
|
|
}
|
|
|
|
|
2016-04-28 22:07:27 +08:00
|
|
|
static struct ceph_mon_generic_request *
|
|
|
|
__ceph_monc_get_version(struct ceph_mon_client *monc, const char *what,
|
|
|
|
ceph_monc_callback_t cb, u64 private_data)
|
2014-05-13 15:19:26 +08:00
|
|
|
{
|
|
|
|
struct ceph_mon_generic_request *req;
|
|
|
|
|
2016-04-28 22:07:27 +08:00
|
|
|
req = alloc_generic_request(monc, GFP_NOIO);
|
2014-05-13 15:19:26 +08:00
|
|
|
if (!req)
|
2016-04-28 22:07:27 +08:00
|
|
|
goto err_put_req;
|
2014-05-13 15:19:26 +08:00
|
|
|
|
|
|
|
req->request = ceph_msg_new(CEPH_MSG_MON_GET_VERSION,
|
|
|
|
sizeof(u64) + sizeof(u32) + strlen(what),
|
2016-04-28 22:07:27 +08:00
|
|
|
GFP_NOIO, true);
|
|
|
|
if (!req->request)
|
|
|
|
goto err_put_req;
|
2014-05-13 15:19:26 +08:00
|
|
|
|
2016-04-28 22:07:27 +08:00
|
|
|
req->reply = ceph_msg_new(CEPH_MSG_MON_GET_VERSION_REPLY, 32, GFP_NOIO,
|
|
|
|
true);
|
|
|
|
if (!req->reply)
|
|
|
|
goto err_put_req;
|
2014-05-13 15:19:26 +08:00
|
|
|
|
2016-04-28 22:07:27 +08:00
|
|
|
req->complete_cb = cb;
|
|
|
|
req->private_data = private_data;
|
2014-05-13 15:19:26 +08:00
|
|
|
|
|
|
|
mutex_lock(&monc->mutex);
|
2016-04-28 22:07:27 +08:00
|
|
|
register_generic_request(req);
|
|
|
|
{
|
|
|
|
void *p = req->request->front.iov_base;
|
|
|
|
void *const end = p + req->request->front_alloc_len;
|
|
|
|
|
|
|
|
ceph_encode_64(&p, req->tid); /* handle */
|
|
|
|
ceph_encode_string(&p, end, what, strlen(what));
|
|
|
|
WARN_ON(p != end);
|
|
|
|
}
|
|
|
|
send_generic_request(monc, req);
|
|
|
|
mutex_unlock(&monc->mutex);
|
2014-05-13 15:19:26 +08:00
|
|
|
|
2016-04-28 22:07:27 +08:00
|
|
|
return req;
|
2014-05-13 15:19:26 +08:00
|
|
|
|
2016-04-28 22:07:27 +08:00
|
|
|
err_put_req:
|
2014-12-23 00:35:17 +08:00
|
|
|
put_generic_request(req);
|
2016-04-28 22:07:27 +08:00
|
|
|
return ERR_PTR(-ENOMEM);
|
2014-05-13 15:19:26 +08:00
|
|
|
}
|
2016-04-28 22:07:27 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Send MMonGetVersion and wait for the reply.
|
|
|
|
*
|
|
|
|
* @what: one of "mdsmap", "osdmap" or "monmap"
|
|
|
|
*/
|
|
|
|
int ceph_monc_get_version(struct ceph_mon_client *monc, const char *what,
|
|
|
|
u64 *newest)
|
|
|
|
{
|
|
|
|
struct ceph_mon_generic_request *req;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
req = __ceph_monc_get_version(monc, what, NULL, 0);
|
|
|
|
if (IS_ERR(req))
|
|
|
|
return PTR_ERR(req);
|
|
|
|
|
|
|
|
ret = wait_generic_request(req);
|
|
|
|
if (!ret)
|
|
|
|
*newest = req->u.newest;
|
|
|
|
|
|
|
|
put_generic_request(req);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(ceph_monc_get_version);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send MMonGetVersion,
|
|
|
|
*
|
|
|
|
* @what: one of "mdsmap", "osdmap" or "monmap"
|
|
|
|
*/
|
|
|
|
int ceph_monc_get_version_async(struct ceph_mon_client *monc, const char *what,
|
|
|
|
ceph_monc_callback_t cb, u64 private_data)
|
|
|
|
{
|
|
|
|
struct ceph_mon_generic_request *req;
|
|
|
|
|
|
|
|
req = __ceph_monc_get_version(monc, what, cb, private_data);
|
|
|
|
if (IS_ERR(req))
|
|
|
|
return PTR_ERR(req);
|
|
|
|
|
|
|
|
put_generic_request(req);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(ceph_monc_get_version_async);
|
2014-05-13 15:19:26 +08:00
|
|
|
|
2015-07-23 08:59:52 +08:00
|
|
|
static void handle_command_ack(struct ceph_mon_client *monc,
|
|
|
|
struct ceph_msg *msg)
|
|
|
|
{
|
|
|
|
struct ceph_mon_generic_request *req;
|
|
|
|
void *p = msg->front.iov_base;
|
|
|
|
void *const end = p + msg->front_alloc_len;
|
|
|
|
u64 tid = le64_to_cpu(msg->hdr.tid);
|
|
|
|
|
|
|
|
dout("%s msg %p tid %llu\n", __func__, msg, tid);
|
|
|
|
|
|
|
|
ceph_decode_need(&p, end, sizeof(struct ceph_mon_request_header) +
|
|
|
|
sizeof(u32), bad);
|
|
|
|
p += sizeof(struct ceph_mon_request_header);
|
|
|
|
|
|
|
|
mutex_lock(&monc->mutex);
|
|
|
|
req = lookup_generic_request(&monc->generic_request_tree, tid);
|
|
|
|
if (!req) {
|
|
|
|
mutex_unlock(&monc->mutex);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
req->result = ceph_decode_32(&p);
|
|
|
|
__finish_generic_request(req);
|
|
|
|
mutex_unlock(&monc->mutex);
|
|
|
|
|
|
|
|
complete_generic_request(req);
|
|
|
|
return;
|
|
|
|
|
|
|
|
bad:
|
|
|
|
pr_err("corrupt mon_command ack, tid %llu\n", tid);
|
|
|
|
ceph_msg_dump(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
int ceph_monc_blacklist_add(struct ceph_mon_client *monc,
|
|
|
|
struct ceph_entity_addr *client_addr)
|
|
|
|
{
|
|
|
|
struct ceph_mon_generic_request *req;
|
|
|
|
struct ceph_mon_command *h;
|
|
|
|
int ret = -ENOMEM;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
req = alloc_generic_request(monc, GFP_NOIO);
|
|
|
|
if (!req)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
req->request = ceph_msg_new(CEPH_MSG_MON_COMMAND, 256, GFP_NOIO, true);
|
|
|
|
if (!req->request)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
req->reply = ceph_msg_new(CEPH_MSG_MON_COMMAND_ACK, 512, GFP_NOIO,
|
|
|
|
true);
|
|
|
|
if (!req->reply)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
mutex_lock(&monc->mutex);
|
|
|
|
register_generic_request(req);
|
|
|
|
h = req->request->front.iov_base;
|
|
|
|
h->monhdr.have_version = 0;
|
|
|
|
h->monhdr.session_mon = cpu_to_le16(-1);
|
|
|
|
h->monhdr.session_mon_tid = 0;
|
|
|
|
h->fsid = monc->monmap->fsid;
|
|
|
|
h->num_strs = cpu_to_le32(1);
|
|
|
|
len = sprintf(h->str, "{ \"prefix\": \"osd blacklist\", \
|
|
|
|
\"blacklistop\": \"add\", \
|
|
|
|
\"addr\": \"%pISpc/%u\" }",
|
|
|
|
&client_addr->in_addr, le32_to_cpu(client_addr->nonce));
|
|
|
|
h->str_len = cpu_to_le32(len);
|
|
|
|
send_generic_request(monc, req);
|
|
|
|
mutex_unlock(&monc->mutex);
|
|
|
|
|
|
|
|
ret = wait_generic_request(req);
|
|
|
|
out:
|
|
|
|
put_generic_request(req);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(ceph_monc_blacklist_add);
|
|
|
|
|
2009-10-07 02:31:11 +08:00
|
|
|
/*
|
2010-05-18 03:40:28 +08:00
|
|
|
* Resend pending generic requests.
|
2009-10-07 02:31:11 +08:00
|
|
|
*/
|
2010-04-23 06:40:37 +08:00
|
|
|
static void __resend_generic_request(struct ceph_mon_client *monc)
|
2009-10-07 02:31:11 +08:00
|
|
|
{
|
2010-04-23 06:40:37 +08:00
|
|
|
struct ceph_mon_generic_request *req;
|
2010-02-16 06:47:28 +08:00
|
|
|
struct rb_node *p;
|
2009-10-07 02:31:11 +08:00
|
|
|
|
2010-04-23 06:40:37 +08:00
|
|
|
for (p = rb_first(&monc->generic_request_tree); p; p = rb_next(p)) {
|
|
|
|
req = rb_entry(p, struct ceph_mon_generic_request, node);
|
2012-06-02 03:56:43 +08:00
|
|
|
ceph_msg_revoke(req->request);
|
2012-07-31 09:16:40 +08:00
|
|
|
ceph_msg_revoke_incoming(req->reply);
|
2012-05-27 12:26:43 +08:00
|
|
|
ceph_con_send(&monc->con, ceph_msg_get(req->request));
|
2009-10-07 02:31:11 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Delayed work. If we haven't mounted yet, retry. Otherwise,
|
|
|
|
* renew/retry subscription as needed (in case it is timing out, or we
|
|
|
|
* got an ENOMEM). And keep the monitor connection alive.
|
|
|
|
*/
|
|
|
|
static void delayed_work(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct ceph_mon_client *monc =
|
|
|
|
container_of(work, struct ceph_mon_client, delayed_work.work);
|
|
|
|
|
|
|
|
dout("monc delayed_work\n");
|
|
|
|
mutex_lock(&monc->mutex);
|
2009-11-19 08:19:57 +08:00
|
|
|
if (monc->hunting) {
|
2016-01-21 23:33:25 +08:00
|
|
|
dout("%s continuing hunt\n", __func__);
|
|
|
|
reopen_session(monc);
|
2009-10-07 02:31:11 +08:00
|
|
|
} else {
|
2015-09-01 17:19:38 +08:00
|
|
|
int is_auth = ceph_auth_is_authenticated(monc->auth);
|
|
|
|
if (ceph_con_keepalive_expired(&monc->con,
|
2016-01-21 23:33:15 +08:00
|
|
|
CEPH_MONC_PING_TIMEOUT)) {
|
2015-09-01 17:19:38 +08:00
|
|
|
dout("monc keepalive timeout\n");
|
|
|
|
is_auth = 0;
|
2016-01-21 23:33:25 +08:00
|
|
|
reopen_session(monc);
|
2015-09-01 17:19:38 +08:00
|
|
|
}
|
2010-02-03 08:21:06 +08:00
|
|
|
|
2015-09-01 17:19:38 +08:00
|
|
|
if (!monc->hunting) {
|
|
|
|
ceph_con_keepalive(&monc->con);
|
|
|
|
__validate_auth(monc);
|
2018-04-23 21:25:10 +08:00
|
|
|
un_backoff(monc);
|
2015-09-01 17:19:38 +08:00
|
|
|
}
|
2010-02-03 08:21:06 +08:00
|
|
|
|
2017-06-05 20:45:00 +08:00
|
|
|
if (is_auth &&
|
|
|
|
!(monc->con.peer_features & CEPH_FEATURE_MON_STATEFUL_SUB)) {
|
2016-01-19 23:19:06 +08:00
|
|
|
unsigned long now = jiffies;
|
|
|
|
|
|
|
|
dout("%s renew subs? now %lu renew after %lu\n",
|
|
|
|
__func__, now, monc->sub_renew_after);
|
|
|
|
if (time_after_eq(now, monc->sub_renew_after))
|
|
|
|
__send_subscribe(monc);
|
|
|
|
}
|
2009-10-07 02:31:11 +08:00
|
|
|
}
|
|
|
|
__schedule_delayed(monc);
|
|
|
|
mutex_unlock(&monc->mutex);
|
|
|
|
}
|
|
|
|
|
2009-10-28 02:50:50 +08:00
|
|
|
/*
|
|
|
|
* On startup, we build a temporary monmap populated with the IPs
|
|
|
|
* provided by mount(2).
|
|
|
|
*/
|
|
|
|
static int build_initial_monmap(struct ceph_mon_client *monc)
|
|
|
|
{
|
2010-04-07 06:14:15 +08:00
|
|
|
struct ceph_options *opt = monc->client->options;
|
|
|
|
struct ceph_entity_addr *mon_addr = opt->mon_addr;
|
|
|
|
int num_mon = opt->num_mon;
|
2009-10-28 02:50:50 +08:00
|
|
|
int i;
|
|
|
|
|
|
|
|
/* build initial monmap */
|
treewide: Use struct_size() for kmalloc()-family
One of the more common cases of allocation size calculations is finding
the size of a structure that has a zero-sized array at the end, along
with memory for some number of elements for that array. For example:
struct foo {
int stuff;
void *entry[];
};
instance = kmalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL);
Instead of leaving these open-coded and prone to type mistakes, we can
now use the new struct_size() helper:
instance = kmalloc(struct_size(instance, entry, count), GFP_KERNEL);
This patch makes the changes for kmalloc()-family (and kvmalloc()-family)
uses. It was done via automatic conversion with manual review for the
"CHECKME" non-standard cases noted below, using the following Coccinelle
script:
// pkey_cache = kmalloc(sizeof *pkey_cache + tprops->pkey_tbl_len *
// sizeof *pkey_cache->table, GFP_KERNEL);
@@
identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
expression GFP;
identifier VAR, ELEMENT;
expression COUNT;
@@
- alloc(sizeof(*VAR) + COUNT * sizeof(*VAR->ELEMENT), GFP)
+ alloc(struct_size(VAR, ELEMENT, COUNT), GFP)
// mr = kzalloc(sizeof(*mr) + m * sizeof(mr->map[0]), GFP_KERNEL);
@@
identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
expression GFP;
identifier VAR, ELEMENT;
expression COUNT;
@@
- alloc(sizeof(*VAR) + COUNT * sizeof(VAR->ELEMENT[0]), GFP)
+ alloc(struct_size(VAR, ELEMENT, COUNT), GFP)
// Same pattern, but can't trivially locate the trailing element name,
// or variable name.
@@
identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
expression GFP;
expression SOMETHING, COUNT, ELEMENT;
@@
- alloc(sizeof(SOMETHING) + COUNT * sizeof(ELEMENT), GFP)
+ alloc(CHECKME_struct_size(&SOMETHING, ELEMENT, COUNT), GFP)
Signed-off-by: Kees Cook <keescook@chromium.org>
2018-05-09 04:45:50 +08:00
|
|
|
monc->monmap = kzalloc(struct_size(monc->monmap, mon_inst, num_mon),
|
2009-10-28 02:50:50 +08:00
|
|
|
GFP_KERNEL);
|
|
|
|
if (!monc->monmap)
|
|
|
|
return -ENOMEM;
|
|
|
|
for (i = 0; i < num_mon; i++) {
|
|
|
|
monc->monmap->mon_inst[i].addr = mon_addr[i];
|
|
|
|
monc->monmap->mon_inst[i].addr.nonce = 0;
|
|
|
|
monc->monmap->mon_inst[i].name.type =
|
|
|
|
CEPH_ENTITY_TYPE_MON;
|
|
|
|
monc->monmap->mon_inst[i].name.num = cpu_to_le64(i);
|
|
|
|
}
|
|
|
|
monc->monmap->num_mon = num_mon;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-10-07 02:31:11 +08:00
|
|
|
int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl)
|
|
|
|
{
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
dout("init\n");
|
|
|
|
memset(monc, 0, sizeof(*monc));
|
|
|
|
monc->client = cl;
|
|
|
|
monc->monmap = NULL;
|
|
|
|
mutex_init(&monc->mutex);
|
|
|
|
|
2009-10-28 02:50:50 +08:00
|
|
|
err = build_initial_monmap(monc);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
|
2011-08-10 00:27:44 +08:00
|
|
|
/* connection */
|
2009-11-19 08:19:57 +08:00
|
|
|
/* authentication */
|
2010-04-07 06:14:15 +08:00
|
|
|
monc->auth = ceph_auth_init(cl->options->name,
|
2011-03-26 07:32:57 +08:00
|
|
|
cl->options->key);
|
2011-09-13 05:51:58 +08:00
|
|
|
if (IS_ERR(monc->auth)) {
|
|
|
|
err = PTR_ERR(monc->auth);
|
2012-05-27 12:26:43 +08:00
|
|
|
goto out_monmap;
|
2011-09-13 05:51:58 +08:00
|
|
|
}
|
2009-11-19 08:19:57 +08:00
|
|
|
monc->auth->want_keys =
|
|
|
|
CEPH_ENTITY_TYPE_AUTH | CEPH_ENTITY_TYPE_MON |
|
|
|
|
CEPH_ENTITY_TYPE_OSD | CEPH_ENTITY_TYPE_MDS;
|
|
|
|
|
2010-05-22 05:57:25 +08:00
|
|
|
/* msgs */
|
2010-04-02 07:06:19 +08:00
|
|
|
err = -ENOMEM;
|
2010-03-25 12:52:30 +08:00
|
|
|
monc->m_subscribe_ack = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE_ACK,
|
2010-04-07 05:33:58 +08:00
|
|
|
sizeof(struct ceph_mon_subscribe_ack),
|
2016-12-02 23:35:08 +08:00
|
|
|
GFP_KERNEL, true);
|
2010-04-02 07:06:19 +08:00
|
|
|
if (!monc->m_subscribe_ack)
|
2011-09-13 05:51:58 +08:00
|
|
|
goto out_auth;
|
2010-03-25 12:48:05 +08:00
|
|
|
|
2016-12-02 23:35:08 +08:00
|
|
|
monc->m_subscribe = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE, 128,
|
|
|
|
GFP_KERNEL, true);
|
2010-05-22 05:57:25 +08:00
|
|
|
if (!monc->m_subscribe)
|
|
|
|
goto out_subscribe_ack;
|
|
|
|
|
2016-12-02 23:35:08 +08:00
|
|
|
monc->m_auth_reply = ceph_msg_new(CEPH_MSG_AUTH_REPLY, 4096,
|
|
|
|
GFP_KERNEL, true);
|
2010-04-02 07:06:19 +08:00
|
|
|
if (!monc->m_auth_reply)
|
2010-05-22 05:57:25 +08:00
|
|
|
goto out_subscribe;
|
2009-11-19 08:19:57 +08:00
|
|
|
|
2016-12-02 23:35:08 +08:00
|
|
|
monc->m_auth = ceph_msg_new(CEPH_MSG_AUTH, 4096, GFP_KERNEL, true);
|
2010-02-03 08:21:06 +08:00
|
|
|
monc->pending_auth = 0;
|
2010-04-02 07:06:19 +08:00
|
|
|
if (!monc->m_auth)
|
2010-03-25 12:48:05 +08:00
|
|
|
goto out_auth_reply;
|
2009-10-07 02:31:11 +08:00
|
|
|
|
2012-06-28 03:24:34 +08:00
|
|
|
ceph_con_init(&monc->con, monc, &mon_con_ops,
|
|
|
|
&monc->client->msgr);
|
|
|
|
|
2009-10-07 02:31:11 +08:00
|
|
|
monc->cur_mon = -1;
|
2016-01-21 23:33:19 +08:00
|
|
|
monc->had_a_connection = false;
|
|
|
|
monc->hunt_mult = 1;
|
2009-10-07 02:31:11 +08:00
|
|
|
|
|
|
|
INIT_DELAYED_WORK(&monc->delayed_work, delayed_work);
|
2010-04-23 06:40:37 +08:00
|
|
|
monc->generic_request_tree = RB_ROOT;
|
2009-10-07 02:31:11 +08:00
|
|
|
monc->last_tid = 0;
|
|
|
|
|
2016-05-26 06:05:01 +08:00
|
|
|
monc->fs_cluster_id = CEPH_FS_CLUSTER_ID_NONE;
|
|
|
|
|
2009-11-19 08:19:57 +08:00
|
|
|
return 0;
|
|
|
|
|
2010-03-25 12:48:05 +08:00
|
|
|
out_auth_reply:
|
|
|
|
ceph_msg_put(monc->m_auth_reply);
|
2010-05-22 05:57:25 +08:00
|
|
|
out_subscribe:
|
|
|
|
ceph_msg_put(monc->m_subscribe);
|
2010-03-25 12:52:30 +08:00
|
|
|
out_subscribe_ack:
|
|
|
|
ceph_msg_put(monc->m_subscribe_ack);
|
2011-09-13 05:51:58 +08:00
|
|
|
out_auth:
|
|
|
|
ceph_auth_destroy(monc->auth);
|
2009-11-19 08:19:57 +08:00
|
|
|
out_monmap:
|
|
|
|
kfree(monc->monmap);
|
2009-10-07 02:31:11 +08:00
|
|
|
out:
|
|
|
|
return err;
|
|
|
|
}
|
2010-04-07 06:14:15 +08:00
|
|
|
EXPORT_SYMBOL(ceph_monc_init);
|
2009-10-07 02:31:11 +08:00
|
|
|
|
|
|
|
void ceph_monc_stop(struct ceph_mon_client *monc)
|
|
|
|
{
|
|
|
|
dout("stop\n");
|
|
|
|
cancel_delayed_work_sync(&monc->delayed_work);
|
|
|
|
|
|
|
|
mutex_lock(&monc->mutex);
|
|
|
|
__close_session(monc);
|
2016-01-21 00:50:31 +08:00
|
|
|
monc->cur_mon = -1;
|
2009-10-07 02:31:11 +08:00
|
|
|
mutex_unlock(&monc->mutex);
|
|
|
|
|
2012-06-11 11:43:56 +08:00
|
|
|
/*
|
|
|
|
* flush msgr queue before we destroy ourselves to ensure that:
|
|
|
|
* - any work that references our embedded con is finished.
|
|
|
|
* - any osd_client or other work that may reference an authorizer
|
|
|
|
* finishes before we shut down the auth subsystem.
|
|
|
|
*/
|
|
|
|
ceph_msgr_flush();
|
|
|
|
|
2009-11-19 08:19:57 +08:00
|
|
|
ceph_auth_destroy(monc->auth);
|
|
|
|
|
2016-04-28 22:07:27 +08:00
|
|
|
WARN_ON(!RB_EMPTY_ROOT(&monc->generic_request_tree));
|
|
|
|
|
2009-11-19 08:19:57 +08:00
|
|
|
ceph_msg_put(monc->m_auth);
|
2010-03-25 12:48:05 +08:00
|
|
|
ceph_msg_put(monc->m_auth_reply);
|
2010-05-22 05:57:25 +08:00
|
|
|
ceph_msg_put(monc->m_subscribe);
|
2010-03-25 12:52:30 +08:00
|
|
|
ceph_msg_put(monc->m_subscribe_ack);
|
2009-10-07 02:31:11 +08:00
|
|
|
|
|
|
|
kfree(monc->monmap);
|
|
|
|
}
|
2010-04-07 06:14:15 +08:00
|
|
|
EXPORT_SYMBOL(ceph_monc_stop);
|
2009-10-07 02:31:11 +08:00
|
|
|
|
2016-01-09 02:17:22 +08:00
|
|
|
static void finish_hunting(struct ceph_mon_client *monc)
|
|
|
|
{
|
|
|
|
if (monc->hunting) {
|
|
|
|
dout("%s found mon%d\n", __func__, monc->cur_mon);
|
|
|
|
monc->hunting = false;
|
2016-01-21 23:33:19 +08:00
|
|
|
monc->had_a_connection = true;
|
2018-04-23 21:25:10 +08:00
|
|
|
un_backoff(monc);
|
2018-04-23 21:25:10 +08:00
|
|
|
__schedule_delayed(monc);
|
2016-01-09 02:17:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-19 08:19:57 +08:00
|
|
|
static void handle_auth_reply(struct ceph_mon_client *monc,
|
|
|
|
struct ceph_msg *msg)
|
|
|
|
{
|
|
|
|
int ret;
|
2010-05-26 06:38:06 +08:00
|
|
|
int was_auth = 0;
|
2009-11-19 08:19:57 +08:00
|
|
|
|
|
|
|
mutex_lock(&monc->mutex);
|
2013-03-26 01:26:14 +08:00
|
|
|
was_auth = ceph_auth_is_authenticated(monc->auth);
|
2010-02-03 08:21:06 +08:00
|
|
|
monc->pending_auth = 0;
|
2009-11-19 08:19:57 +08:00
|
|
|
ret = ceph_handle_auth_reply(monc->auth, msg->front.iov_base,
|
|
|
|
msg->front.iov_len,
|
|
|
|
monc->m_auth->front.iov_base,
|
2014-01-10 02:08:21 +08:00
|
|
|
monc->m_auth->front_alloc_len);
|
2016-01-09 02:17:22 +08:00
|
|
|
if (ret > 0) {
|
|
|
|
__send_prepared_auth_request(monc, ret);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
finish_hunting(monc);
|
|
|
|
|
2009-11-19 08:19:57 +08:00
|
|
|
if (ret < 0) {
|
2010-02-03 08:21:06 +08:00
|
|
|
monc->client->auth_err = ret;
|
2013-03-26 01:26:14 +08:00
|
|
|
} else if (!was_auth && ceph_auth_is_authenticated(monc->auth)) {
|
2009-11-19 08:19:57 +08:00
|
|
|
dout("authenticated, starting session\n");
|
2009-11-19 08:50:41 +08:00
|
|
|
|
2012-05-27 12:26:43 +08:00
|
|
|
monc->client->msgr.inst.name.type = CEPH_ENTITY_TYPE_CLIENT;
|
|
|
|
monc->client->msgr.inst.name.num =
|
2010-06-12 06:57:06 +08:00
|
|
|
cpu_to_le64(monc->auth->global_id);
|
2009-11-19 08:50:41 +08:00
|
|
|
|
2009-11-19 08:19:57 +08:00
|
|
|
__send_subscribe(monc);
|
2010-04-23 06:40:37 +08:00
|
|
|
__resend_generic_request(monc);
|
2016-01-09 02:17:22 +08:00
|
|
|
|
|
|
|
pr_info("mon%d %s session established\n", monc->cur_mon,
|
|
|
|
ceph_pr_addr(&monc->con.peer_addr.in_addr));
|
2009-11-19 08:19:57 +08:00
|
|
|
}
|
2016-01-09 02:17:22 +08:00
|
|
|
|
|
|
|
out:
|
2009-11-19 08:19:57 +08:00
|
|
|
mutex_unlock(&monc->mutex);
|
2016-01-09 02:17:22 +08:00
|
|
|
if (monc->client->auth_err < 0)
|
|
|
|
wake_up_all(&monc->client->auth_wq);
|
2009-11-19 08:19:57 +08:00
|
|
|
}
|
|
|
|
|
2010-02-03 08:21:06 +08:00
|
|
|
static int __validate_auth(struct ceph_mon_client *monc)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (monc->pending_auth)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ret = ceph_build_auth(monc->auth, monc->m_auth->front.iov_base,
|
2014-01-10 02:08:21 +08:00
|
|
|
monc->m_auth->front_alloc_len);
|
2010-02-03 08:21:06 +08:00
|
|
|
if (ret <= 0)
|
|
|
|
return ret; /* either an error, or no need to authenticate */
|
|
|
|
__send_prepared_auth_request(monc, ret);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ceph_monc_validate_auth(struct ceph_mon_client *monc)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
mutex_lock(&monc->mutex);
|
|
|
|
ret = __validate_auth(monc);
|
|
|
|
mutex_unlock(&monc->mutex);
|
|
|
|
return ret;
|
|
|
|
}
|
2010-04-07 06:14:15 +08:00
|
|
|
EXPORT_SYMBOL(ceph_monc_validate_auth);
|
2010-02-03 08:21:06 +08:00
|
|
|
|
2009-10-07 02:31:11 +08:00
|
|
|
/*
|
|
|
|
* handle incoming message
|
|
|
|
*/
|
|
|
|
static void dispatch(struct ceph_connection *con, struct ceph_msg *msg)
|
|
|
|
{
|
|
|
|
struct ceph_mon_client *monc = con->private;
|
|
|
|
int type = le16_to_cpu(msg->hdr.type);
|
|
|
|
|
|
|
|
if (!monc)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (type) {
|
2009-11-19 08:19:57 +08:00
|
|
|
case CEPH_MSG_AUTH_REPLY:
|
|
|
|
handle_auth_reply(monc, msg);
|
2009-10-07 02:31:11 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CEPH_MSG_MON_SUBSCRIBE_ACK:
|
|
|
|
handle_subscribe_ack(monc, msg);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CEPH_MSG_STATFS_REPLY:
|
|
|
|
handle_statfs_reply(monc, msg);
|
|
|
|
break;
|
|
|
|
|
2014-05-13 15:19:26 +08:00
|
|
|
case CEPH_MSG_MON_GET_VERSION_REPLY:
|
|
|
|
handle_get_version_reply(monc, msg);
|
|
|
|
break;
|
|
|
|
|
2015-07-23 08:59:52 +08:00
|
|
|
case CEPH_MSG_MON_COMMAND_ACK:
|
|
|
|
handle_command_ack(monc, msg);
|
|
|
|
break;
|
|
|
|
|
2009-11-19 08:19:57 +08:00
|
|
|
case CEPH_MSG_MON_MAP:
|
|
|
|
ceph_monc_handle_map(monc, msg);
|
|
|
|
break;
|
|
|
|
|
2009-10-07 02:31:11 +08:00
|
|
|
case CEPH_MSG_OSD_MAP:
|
|
|
|
ceph_osdc_handle_map(&monc->client->osdc, msg);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2010-04-07 06:14:15 +08:00
|
|
|
/* can the chained handler handle it? */
|
|
|
|
if (monc->client->extra_mon_dispatch &&
|
|
|
|
monc->client->extra_mon_dispatch(monc->client, msg) == 0)
|
|
|
|
break;
|
2018-07-25 03:29:07 +08:00
|
|
|
|
2009-10-07 02:31:11 +08:00
|
|
|
pr_err("received unknown message type %d %s\n", type,
|
|
|
|
ceph_msg_type_name(type));
|
|
|
|
}
|
|
|
|
ceph_msg_put(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate memory for incoming message
|
|
|
|
*/
|
|
|
|
static struct ceph_msg *mon_alloc_msg(struct ceph_connection *con,
|
2010-01-09 05:58:34 +08:00
|
|
|
struct ceph_msg_header *hdr,
|
|
|
|
int *skip)
|
2009-10-07 02:31:11 +08:00
|
|
|
{
|
|
|
|
struct ceph_mon_client *monc = con->private;
|
|
|
|
int type = le16_to_cpu(hdr->type);
|
2010-01-09 05:58:34 +08:00
|
|
|
int front_len = le32_to_cpu(hdr->front_len);
|
2010-02-20 13:43:23 +08:00
|
|
|
struct ceph_msg *m = NULL;
|
2009-10-07 02:31:11 +08:00
|
|
|
|
2010-01-09 05:58:34 +08:00
|
|
|
*skip = 0;
|
2010-01-12 06:47:13 +08:00
|
|
|
|
2009-10-07 02:31:11 +08:00
|
|
|
switch (type) {
|
|
|
|
case CEPH_MSG_MON_SUBSCRIBE_ACK:
|
2010-03-25 12:52:30 +08:00
|
|
|
m = ceph_msg_get(monc->m_subscribe_ack);
|
2010-01-09 05:58:34 +08:00
|
|
|
break;
|
2009-10-07 02:31:11 +08:00
|
|
|
case CEPH_MSG_STATFS_REPLY:
|
2015-07-23 08:59:52 +08:00
|
|
|
case CEPH_MSG_MON_COMMAND_ACK:
|
2010-04-23 06:40:37 +08:00
|
|
|
return get_generic_reply(con, hdr, skip);
|
2009-11-19 08:19:57 +08:00
|
|
|
case CEPH_MSG_AUTH_REPLY:
|
2010-03-25 12:48:05 +08:00
|
|
|
m = ceph_msg_get(monc->m_auth_reply);
|
2010-01-09 05:58:34 +08:00
|
|
|
break;
|
2014-05-13 15:19:26 +08:00
|
|
|
case CEPH_MSG_MON_GET_VERSION_REPLY:
|
|
|
|
if (le64_to_cpu(hdr->tid) != 0)
|
|
|
|
return get_generic_reply(con, hdr, skip);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Older OSDs don't set reply tid even if the orignal
|
2017-10-16 01:55:23 +08:00
|
|
|
* request had a non-zero tid. Work around this weirdness
|
|
|
|
* by allocating a new message.
|
2014-05-13 15:19:26 +08:00
|
|
|
*/
|
2017-10-16 01:55:23 +08:00
|
|
|
/* fall through */
|
2010-02-20 13:43:23 +08:00
|
|
|
case CEPH_MSG_MON_MAP:
|
|
|
|
case CEPH_MSG_MDS_MAP:
|
|
|
|
case CEPH_MSG_OSD_MAP:
|
2016-04-07 11:34:43 +08:00
|
|
|
case CEPH_MSG_FS_MAP_USER:
|
2011-08-10 06:03:46 +08:00
|
|
|
m = ceph_msg_new(type, front_len, GFP_NOFS, false);
|
2012-06-05 03:43:32 +08:00
|
|
|
if (!m)
|
|
|
|
return NULL; /* ENOMEM--return skip == 0 */
|
2010-02-20 13:43:23 +08:00
|
|
|
break;
|
2009-10-07 02:31:11 +08:00
|
|
|
}
|
2010-01-09 05:58:34 +08:00
|
|
|
|
2010-02-20 13:43:23 +08:00
|
|
|
if (!m) {
|
|
|
|
pr_info("alloc_msg unknown type %d\n", type);
|
2010-01-09 05:58:34 +08:00
|
|
|
*skip = 1;
|
2014-08-04 22:01:54 +08:00
|
|
|
} else if (front_len > m->front_alloc_len) {
|
2014-09-10 12:17:29 +08:00
|
|
|
pr_warn("mon_alloc_msg front %d > prealloc %d (%u#%llu)\n",
|
|
|
|
front_len, m->front_alloc_len,
|
|
|
|
(unsigned int)con->peer_name.type,
|
|
|
|
le64_to_cpu(con->peer_name.num));
|
2014-08-04 22:01:54 +08:00
|
|
|
ceph_msg_put(m);
|
|
|
|
m = ceph_msg_new(type, front_len, GFP_NOFS, false);
|
2010-02-20 13:43:23 +08:00
|
|
|
}
|
2014-08-04 22:01:54 +08:00
|
|
|
|
2010-01-09 05:58:34 +08:00
|
|
|
return m;
|
2009-10-07 02:31:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the monitor connection resets, pick a new monitor and resubmit
|
|
|
|
* any pending requests.
|
|
|
|
*/
|
|
|
|
static void mon_fault(struct ceph_connection *con)
|
|
|
|
{
|
|
|
|
struct ceph_mon_client *monc = con->private;
|
|
|
|
|
|
|
|
mutex_lock(&monc->mutex);
|
2016-01-23 22:57:51 +08:00
|
|
|
dout("%s mon%d\n", __func__, monc->cur_mon);
|
|
|
|
if (monc->cur_mon >= 0) {
|
|
|
|
if (!monc->hunting) {
|
|
|
|
dout("%s hunting for new mon\n", __func__);
|
|
|
|
reopen_session(monc);
|
|
|
|
__schedule_delayed(monc);
|
|
|
|
} else {
|
|
|
|
dout("%s already hunting\n", __func__);
|
|
|
|
}
|
2009-10-07 02:31:11 +08:00
|
|
|
}
|
|
|
|
mutex_unlock(&monc->mutex);
|
|
|
|
}
|
|
|
|
|
2012-06-01 11:27:50 +08:00
|
|
|
/*
|
|
|
|
* We can ignore refcounting on the connection struct, as all references
|
|
|
|
* will come from the messenger workqueue, which is drained prior to
|
|
|
|
* mon_client destruction.
|
|
|
|
*/
|
|
|
|
static struct ceph_connection *con_get(struct ceph_connection *con)
|
|
|
|
{
|
|
|
|
return con;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void con_put(struct ceph_connection *con)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-05-20 16:40:19 +08:00
|
|
|
static const struct ceph_connection_operations mon_con_ops = {
|
2012-06-01 11:27:50 +08:00
|
|
|
.get = con_get,
|
|
|
|
.put = con_put,
|
2009-10-07 02:31:11 +08:00
|
|
|
.dispatch = dispatch,
|
|
|
|
.fault = mon_fault,
|
|
|
|
.alloc_msg = mon_alloc_msg,
|
|
|
|
};
|