2010-04-07 06:14:15 +08:00
|
|
|
#include <linux/ceph/ceph_debug.h>
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/fs_struct.h>
|
|
|
|
#include <linux/namei.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>
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
#include <linux/sched.h>
|
2016-04-14 06:30:17 +08:00
|
|
|
#include <linux/xattr.h>
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
|
|
|
|
#include "super.h"
|
2010-04-07 06:14:15 +08:00
|
|
|
#include "mds_client.h"
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Directory operations: readdir, lookup, create, link, unlink,
|
|
|
|
* rename, etc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ceph MDS operations are specified in terms of a base ino and
|
|
|
|
* relative path. Thus, the client can specify an operation on a
|
|
|
|
* specific inode (e.g., a getattr due to fstat(2)), or as a path
|
|
|
|
* relative to, say, the root directory.
|
|
|
|
*
|
|
|
|
* Normally, we limit ourselves to strict inode ops (no path component)
|
|
|
|
* or dentry operations (a single path component relative to an ino). The
|
|
|
|
* exception to this is open_root_dentry(), which will open the mount
|
|
|
|
* point by name.
|
|
|
|
*/
|
|
|
|
|
2010-08-04 01:25:30 +08:00
|
|
|
const struct dentry_operations ceph_dentry_ops;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize ceph dentry state.
|
|
|
|
*/
|
2016-10-29 10:05:13 +08:00
|
|
|
static int ceph_d_init(struct dentry *dentry)
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
{
|
|
|
|
struct ceph_dentry_info *di;
|
|
|
|
|
2016-03-13 15:26:29 +08:00
|
|
|
di = kmem_cache_zalloc(ceph_dentry_cachep, GFP_KERNEL);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
if (!di)
|
|
|
|
return -ENOMEM; /* oh well */
|
|
|
|
|
|
|
|
di->dentry = dentry;
|
|
|
|
di->lease_session = NULL;
|
2016-06-22 22:35:04 +08:00
|
|
|
di->time = jiffies;
|
2011-07-27 02:30:15 +08:00
|
|
|
dentry->d_fsdata = di;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
ceph_dentry_lru_add(dentry);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2016-04-29 11:27:30 +08:00
|
|
|
* for f_pos for readdir:
|
|
|
|
* - hash order:
|
|
|
|
* (0xff << 52) | ((24 bits hash) << 28) |
|
|
|
|
* (the nth entry has hash collision);
|
|
|
|
* - frag+name order;
|
|
|
|
* ((frag value) << 28) | (the nth entry in frag);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
*/
|
2016-04-29 11:27:30 +08:00
|
|
|
#define OFFSET_BITS 28
|
|
|
|
#define OFFSET_MASK ((1 << OFFSET_BITS) - 1)
|
|
|
|
#define HASH_ORDER (0xffull << (OFFSET_BITS + 24))
|
|
|
|
loff_t ceph_make_fpos(unsigned high, unsigned off, bool hash_order)
|
|
|
|
{
|
|
|
|
loff_t fpos = ((loff_t)high << 28) | (loff_t)off;
|
|
|
|
if (hash_order)
|
|
|
|
fpos |= HASH_ORDER;
|
|
|
|
return fpos;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool is_hash_order(loff_t p)
|
|
|
|
{
|
|
|
|
return (p & HASH_ORDER) == HASH_ORDER;
|
|
|
|
}
|
|
|
|
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
static unsigned fpos_frag(loff_t p)
|
|
|
|
{
|
2016-04-29 11:27:30 +08:00
|
|
|
return p >> OFFSET_BITS;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
}
|
2016-04-29 11:27:30 +08:00
|
|
|
|
|
|
|
static unsigned fpos_hash(loff_t p)
|
|
|
|
{
|
|
|
|
return ceph_frag_value(fpos_frag(p));
|
|
|
|
}
|
|
|
|
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
static unsigned fpos_off(loff_t p)
|
|
|
|
{
|
2016-04-29 11:27:30 +08:00
|
|
|
return p & OFFSET_MASK;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
}
|
|
|
|
|
2014-02-13 19:40:26 +08:00
|
|
|
static int fpos_cmp(loff_t l, loff_t r)
|
|
|
|
{
|
|
|
|
int v = ceph_frag_compare(fpos_frag(l), fpos_frag(r));
|
|
|
|
if (v)
|
|
|
|
return v;
|
|
|
|
return (int)(fpos_off(l) - fpos_off(r));
|
|
|
|
}
|
|
|
|
|
2015-06-16 20:48:56 +08:00
|
|
|
/*
|
|
|
|
* make note of the last dentry we read, so we can
|
|
|
|
* continue at the same lexicographical point,
|
|
|
|
* regardless of what dir changes take place on the
|
|
|
|
* server.
|
|
|
|
*/
|
|
|
|
static int note_last_dentry(struct ceph_file_info *fi, const char *name,
|
|
|
|
int len, unsigned next_offset)
|
|
|
|
{
|
|
|
|
char *buf = kmalloc(len+1, GFP_KERNEL);
|
|
|
|
if (!buf)
|
|
|
|
return -ENOMEM;
|
|
|
|
kfree(fi->last_name);
|
|
|
|
fi->last_name = buf;
|
|
|
|
memcpy(fi->last_name, name, len);
|
|
|
|
fi->last_name[len] = 0;
|
|
|
|
fi->next_offset = next_offset;
|
|
|
|
dout("note_last_dentry '%s'\n", fi->last_name);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-04-28 17:43:35 +08:00
|
|
|
|
|
|
|
static struct dentry *
|
|
|
|
__dcache_find_get_entry(struct dentry *parent, u64 idx,
|
|
|
|
struct ceph_readdir_cache_control *cache_ctl)
|
|
|
|
{
|
|
|
|
struct inode *dir = d_inode(parent);
|
|
|
|
struct dentry *dentry;
|
|
|
|
unsigned idx_mask = (PAGE_SIZE / sizeof(struct dentry *)) - 1;
|
|
|
|
loff_t ptr_pos = idx * sizeof(struct dentry *);
|
|
|
|
pgoff_t ptr_pgoff = ptr_pos >> PAGE_SHIFT;
|
|
|
|
|
|
|
|
if (ptr_pos >= i_size_read(dir))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (!cache_ctl->page || ptr_pgoff != page_index(cache_ctl->page)) {
|
|
|
|
ceph_readdir_cache_release(cache_ctl);
|
|
|
|
cache_ctl->page = find_lock_page(&dir->i_data, ptr_pgoff);
|
|
|
|
if (!cache_ctl->page) {
|
|
|
|
dout(" page %lu not found\n", ptr_pgoff);
|
|
|
|
return ERR_PTR(-EAGAIN);
|
|
|
|
}
|
|
|
|
/* reading/filling the cache are serialized by
|
|
|
|
i_mutex, no need to use page lock */
|
|
|
|
unlock_page(cache_ctl->page);
|
|
|
|
cache_ctl->dentries = kmap(cache_ctl->page);
|
|
|
|
}
|
|
|
|
|
|
|
|
cache_ctl->index = idx & idx_mask;
|
|
|
|
|
|
|
|
rcu_read_lock();
|
|
|
|
spin_lock(&parent->d_lock);
|
|
|
|
/* check i_size again here, because empty directory can be
|
|
|
|
* marked as complete while not holding the i_mutex. */
|
|
|
|
if (ceph_dir_is_complete_ordered(dir) && ptr_pos < i_size_read(dir))
|
|
|
|
dentry = cache_ctl->dentries[cache_ctl->index];
|
|
|
|
else
|
|
|
|
dentry = NULL;
|
|
|
|
spin_unlock(&parent->d_lock);
|
|
|
|
if (dentry && !lockref_get_not_dead(&dentry->d_lockref))
|
|
|
|
dentry = NULL;
|
|
|
|
rcu_read_unlock();
|
|
|
|
return dentry ? : ERR_PTR(-EAGAIN);
|
|
|
|
}
|
|
|
|
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
/*
|
|
|
|
* When possible, we try to satisfy a readdir by peeking at the
|
|
|
|
* dcache. We make this work by carefully ordering dentries on
|
2014-10-27 07:19:16 +08:00
|
|
|
* d_child when we initially get results back from the MDS, and
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
* falling back to a "normal" sync readdir if any dentries in the dir
|
|
|
|
* are dropped.
|
|
|
|
*
|
2013-03-13 19:44:32 +08:00
|
|
|
* Complete dir indicates that we have all dentries in the dir. It is
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
* defined IFF we hold CEPH_CAP_FILE_SHARED (which will be revoked by
|
|
|
|
* the MDS if/when the directory is modified).
|
|
|
|
*/
|
2014-04-06 14:10:04 +08:00
|
|
|
static int __dcache_readdir(struct file *file, struct dir_context *ctx,
|
|
|
|
u32 shared_gen)
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
{
|
2013-05-18 04:52:26 +08:00
|
|
|
struct ceph_file_info *fi = file->private_data;
|
2014-10-31 13:22:04 +08:00
|
|
|
struct dentry *parent = file->f_path.dentry;
|
2015-03-18 06:25:59 +08:00
|
|
|
struct inode *dir = d_inode(parent);
|
2015-06-16 20:48:56 +08:00
|
|
|
struct dentry *dentry, *last = NULL;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
struct ceph_dentry_info *di;
|
2015-06-16 20:48:56 +08:00
|
|
|
struct ceph_readdir_cache_control cache_ctl = {};
|
2016-04-28 17:43:35 +08:00
|
|
|
u64 idx = 0;
|
|
|
|
int err = 0;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
|
2016-04-29 11:27:30 +08:00
|
|
|
dout("__dcache_readdir %p v%u at %llx\n", dir, shared_gen, ctx->pos);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
|
2016-04-28 17:43:35 +08:00
|
|
|
/* search start position */
|
|
|
|
if (ctx->pos > 2) {
|
|
|
|
u64 count = div_u64(i_size_read(dir), sizeof(struct dentry *));
|
|
|
|
while (count > 0) {
|
|
|
|
u64 step = count >> 1;
|
|
|
|
dentry = __dcache_find_get_entry(parent, idx + step,
|
|
|
|
&cache_ctl);
|
|
|
|
if (!dentry) {
|
|
|
|
/* use linar search */
|
|
|
|
idx = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (IS_ERR(dentry)) {
|
|
|
|
err = PTR_ERR(dentry);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
di = ceph_dentry(dentry);
|
|
|
|
spin_lock(&dentry->d_lock);
|
|
|
|
if (fpos_cmp(di->offset, ctx->pos) < 0) {
|
|
|
|
idx += step + 1;
|
|
|
|
count -= step + 1;
|
|
|
|
} else {
|
|
|
|
count = step;
|
|
|
|
}
|
|
|
|
spin_unlock(&dentry->d_lock);
|
|
|
|
dput(dentry);
|
|
|
|
}
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
|
2016-04-28 17:43:35 +08:00
|
|
|
dout("__dcache_readdir %p cache idx %llu\n", dir, idx);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
}
|
|
|
|
|
2015-06-16 20:48:56 +08:00
|
|
|
|
2016-04-28 17:43:35 +08:00
|
|
|
for (;;) {
|
|
|
|
bool emit_dentry = false;
|
|
|
|
dentry = __dcache_find_get_entry(parent, idx++, &cache_ctl);
|
|
|
|
if (!dentry) {
|
2011-07-27 02:26:18 +08:00
|
|
|
fi->flags |= CEPH_F_ATEND;
|
2015-06-16 20:48:56 +08:00
|
|
|
err = 0;
|
|
|
|
break;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
}
|
2016-04-28 17:43:35 +08:00
|
|
|
if (IS_ERR(dentry)) {
|
|
|
|
err = PTR_ERR(dentry);
|
|
|
|
goto out;
|
2015-06-16 20:48:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
di = ceph_dentry(dentry);
|
|
|
|
spin_lock(&dentry->d_lock);
|
2014-04-06 14:10:04 +08:00
|
|
|
if (di->lease_shared_gen == shared_gen &&
|
2015-06-16 20:48:56 +08:00
|
|
|
d_really_is_positive(dentry) &&
|
|
|
|
fpos_cmp(ctx->pos, di->offset) <= 0) {
|
|
|
|
emit_dentry = true;
|
|
|
|
}
|
2011-01-07 14:49:33 +08:00
|
|
|
spin_unlock(&dentry->d_lock);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
|
2015-06-16 20:48:56 +08:00
|
|
|
if (emit_dentry) {
|
2016-04-29 11:27:30 +08:00
|
|
|
dout(" %llx dentry %p %pd %p\n", di->offset,
|
2015-06-16 20:48:56 +08:00
|
|
|
dentry, dentry, d_inode(dentry));
|
|
|
|
ctx->pos = di->offset;
|
|
|
|
if (!dir_emit(ctx, dentry->d_name.name,
|
|
|
|
dentry->d_name.len,
|
|
|
|
ceph_translate_ino(dentry->d_sb,
|
|
|
|
d_inode(dentry)->i_ino),
|
|
|
|
d_inode(dentry)->i_mode >> 12)) {
|
|
|
|
dput(dentry);
|
|
|
|
err = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ctx->pos++;
|
2014-04-08 21:42:59 +08:00
|
|
|
|
2015-06-16 20:48:56 +08:00
|
|
|
if (last)
|
|
|
|
dput(last);
|
|
|
|
last = dentry;
|
|
|
|
} else {
|
|
|
|
dput(dentry);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
}
|
2015-06-16 20:48:56 +08:00
|
|
|
}
|
2016-04-28 17:43:35 +08:00
|
|
|
out:
|
2015-06-16 20:48:56 +08:00
|
|
|
ceph_readdir_cache_release(&cache_ctl);
|
|
|
|
if (last) {
|
|
|
|
int ret;
|
|
|
|
di = ceph_dentry(last);
|
|
|
|
ret = note_last_dentry(fi, last->d_name.name, last->d_name.len,
|
|
|
|
fpos_off(di->offset) + 1);
|
|
|
|
if (ret < 0)
|
|
|
|
err = ret;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
dput(last);
|
2015-06-16 20:48:56 +08:00
|
|
|
}
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2016-04-29 11:27:30 +08:00
|
|
|
static bool need_send_readdir(struct ceph_file_info *fi, loff_t pos)
|
|
|
|
{
|
|
|
|
if (!fi->last_readdir)
|
|
|
|
return true;
|
|
|
|
if (is_hash_order(pos))
|
|
|
|
return !ceph_frag_contains_value(fi->frag, fpos_hash(pos));
|
|
|
|
else
|
|
|
|
return fi->frag != fpos_frag(pos);
|
|
|
|
}
|
|
|
|
|
2013-05-18 04:52:26 +08:00
|
|
|
static int ceph_readdir(struct file *file, struct dir_context *ctx)
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
{
|
2013-05-18 04:52:26 +08:00
|
|
|
struct ceph_file_info *fi = file->private_data;
|
|
|
|
struct inode *inode = file_inode(file);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
struct ceph_inode_info *ci = ceph_inode(inode);
|
2010-04-07 06:14:15 +08:00
|
|
|
struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
|
|
|
|
struct ceph_mds_client *mdsc = fsc->mdsc;
|
2016-04-28 15:17:40 +08:00
|
|
|
int i;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
int err;
|
|
|
|
u32 ftype;
|
|
|
|
struct ceph_mds_reply_info_parsed *rinfo;
|
|
|
|
|
2016-04-28 15:17:40 +08:00
|
|
|
dout("readdir %p file %p pos %llx\n", inode, file, ctx->pos);
|
2011-07-27 02:26:18 +08:00
|
|
|
if (fi->flags & CEPH_F_ATEND)
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* always start with . and .. */
|
2013-05-18 04:52:26 +08:00
|
|
|
if (ctx->pos == 0) {
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
dout("readdir off 0 -> '.'\n");
|
2013-05-18 04:52:26 +08:00
|
|
|
if (!dir_emit(ctx, ".", 1,
|
2011-01-22 08:44:03 +08:00
|
|
|
ceph_translate_ino(inode->i_sb, inode->i_ino),
|
2013-05-18 04:52:26 +08:00
|
|
|
inode->i_mode >> 12))
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
return 0;
|
2013-05-18 04:52:26 +08:00
|
|
|
ctx->pos = 1;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
}
|
2013-05-18 04:52:26 +08:00
|
|
|
if (ctx->pos == 1) {
|
2014-10-31 13:22:04 +08:00
|
|
|
ino_t ino = parent_ino(file->f_path.dentry);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
dout("readdir off 1 -> '..'\n");
|
2013-05-18 04:52:26 +08:00
|
|
|
if (!dir_emit(ctx, "..", 2,
|
2011-01-22 08:44:03 +08:00
|
|
|
ceph_translate_ino(inode->i_sb, ino),
|
2013-05-18 04:52:26 +08:00
|
|
|
inode->i_mode >> 12))
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
return 0;
|
2013-05-18 04:52:26 +08:00
|
|
|
ctx->pos = 2;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* can we use the dcache? */
|
2011-12-01 01:47:09 +08:00
|
|
|
spin_lock(&ci->i_ceph_lock);
|
2015-06-16 20:48:56 +08:00
|
|
|
if (ceph_test_mount_opt(fsc, DCACHE) &&
|
2010-04-07 06:14:15 +08:00
|
|
|
!ceph_test_mount_opt(fsc, NOASYNCREADDIR) &&
|
2010-07-23 04:47:21 +08:00
|
|
|
ceph_snap(inode) != CEPH_SNAPDIR &&
|
2014-10-22 09:09:56 +08:00
|
|
|
__ceph_dir_is_complete_ordered(ci) &&
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
__ceph_caps_issued_mask(ci, CEPH_CAP_FILE_SHARED, 1)) {
|
2014-04-06 14:10:04 +08:00
|
|
|
u32 shared_gen = ci->i_shared_gen;
|
2011-12-01 01:47:09 +08:00
|
|
|
spin_unlock(&ci->i_ceph_lock);
|
2014-04-06 14:10:04 +08:00
|
|
|
err = __dcache_readdir(file, ctx, shared_gen);
|
2010-10-19 05:04:31 +08:00
|
|
|
if (err != -EAGAIN)
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
return err;
|
2010-10-19 05:04:31 +08:00
|
|
|
} else {
|
2011-12-01 01:47:09 +08:00
|
|
|
spin_unlock(&ci->i_ceph_lock);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* proceed with a normal readdir */
|
|
|
|
more:
|
|
|
|
/* do we have the correct frag content buffered? */
|
2016-04-29 11:27:30 +08:00
|
|
|
if (need_send_readdir(fi, ctx->pos)) {
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
struct ceph_mds_request *req;
|
2016-04-29 11:27:30 +08:00
|
|
|
unsigned frag;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
int op = ceph_snap(inode) == CEPH_SNAPDIR ?
|
|
|
|
CEPH_MDS_OP_LSSNAP : CEPH_MDS_OP_READDIR;
|
|
|
|
|
|
|
|
/* discard old result, if any */
|
2010-03-11 04:03:32 +08:00
|
|
|
if (fi->last_readdir) {
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
ceph_mdsc_put_request(fi->last_readdir);
|
2010-03-11 04:03:32 +08:00
|
|
|
fi->last_readdir = NULL;
|
|
|
|
}
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
|
2016-04-29 11:27:30 +08:00
|
|
|
if (is_hash_order(ctx->pos)) {
|
|
|
|
frag = ceph_choose_frag(ci, fpos_hash(ctx->pos),
|
|
|
|
NULL, NULL);
|
|
|
|
} else {
|
|
|
|
frag = fpos_frag(ctx->pos);
|
|
|
|
}
|
|
|
|
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
dout("readdir fetching %llx.%llx frag %x offset '%s'\n",
|
|
|
|
ceph_vinop(inode), frag, fi->last_name);
|
|
|
|
req = ceph_mdsc_create_request(mdsc, op, USE_AUTH_MDS);
|
|
|
|
if (IS_ERR(req))
|
|
|
|
return PTR_ERR(req);
|
2014-03-29 13:41:15 +08:00
|
|
|
err = ceph_alloc_readdir_reply_buffer(req, inode);
|
|
|
|
if (err) {
|
|
|
|
ceph_mdsc_put_request(req);
|
|
|
|
return err;
|
|
|
|
}
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
/* hints to request -> mds selection code */
|
|
|
|
req->r_direct_mode = USE_AUTH_MDS;
|
|
|
|
req->r_direct_hash = ceph_frag_value(frag);
|
|
|
|
req->r_direct_is_hash = true;
|
2015-03-22 00:54:58 +08:00
|
|
|
if (fi->last_name) {
|
2015-06-13 17:27:05 +08:00
|
|
|
req->r_path2 = kstrdup(fi->last_name, GFP_KERNEL);
|
2015-03-22 00:54:58 +08:00
|
|
|
if (!req->r_path2) {
|
|
|
|
ceph_mdsc_put_request(req);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
}
|
2015-06-16 20:48:56 +08:00
|
|
|
req->r_dir_release_cnt = fi->dir_release_count;
|
|
|
|
req->r_dir_ordered_cnt = fi->dir_ordered_count;
|
|
|
|
req->r_readdir_cache_idx = fi->readdir_cache_idx;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
req->r_readdir_offset = fi->next_offset;
|
|
|
|
req->r_args.readdir.frag = cpu_to_le32(frag);
|
2016-04-27 17:48:30 +08:00
|
|
|
req->r_args.readdir.flags =
|
|
|
|
cpu_to_le16(CEPH_READDIR_REPLY_BITFLAGS);
|
2015-03-22 00:54:58 +08:00
|
|
|
|
|
|
|
req->r_inode = inode;
|
|
|
|
ihold(inode);
|
|
|
|
req->r_dentry = dget(file->f_path.dentry);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
err = ceph_mdsc_do_request(mdsc, NULL, req);
|
|
|
|
if (err < 0) {
|
|
|
|
ceph_mdsc_put_request(req);
|
|
|
|
return err;
|
|
|
|
}
|
2016-04-29 11:27:30 +08:00
|
|
|
dout("readdir got and parsed readdir result=%d on "
|
|
|
|
"frag %x, end=%d, complete=%d, hash_order=%d\n",
|
|
|
|
err, frag,
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
(int)req->r_reply_info.dir_end,
|
2016-04-29 11:27:30 +08:00
|
|
|
(int)req->r_reply_info.dir_complete,
|
|
|
|
(int)req->r_reply_info.hash_order);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
|
2013-09-18 09:44:13 +08:00
|
|
|
rinfo = &req->r_reply_info;
|
|
|
|
if (le32_to_cpu(rinfo->dir_dir->frag) != frag) {
|
|
|
|
frag = le32_to_cpu(rinfo->dir_dir->frag);
|
2016-04-29 11:27:30 +08:00
|
|
|
if (!rinfo->hash_order) {
|
|
|
|
fi->next_offset = req->r_readdir_offset;
|
|
|
|
/* adjust ctx->pos to beginning of frag */
|
|
|
|
ctx->pos = ceph_make_fpos(frag,
|
|
|
|
fi->next_offset,
|
|
|
|
false);
|
|
|
|
}
|
2013-09-18 09:44:13 +08:00
|
|
|
}
|
2015-06-16 20:48:56 +08:00
|
|
|
|
2014-02-27 16:26:24 +08:00
|
|
|
fi->frag = frag;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
fi->last_readdir = req;
|
|
|
|
|
2015-06-16 20:48:56 +08:00
|
|
|
if (req->r_did_prepopulate) {
|
|
|
|
fi->readdir_cache_idx = req->r_readdir_cache_idx;
|
|
|
|
if (fi->readdir_cache_idx < 0) {
|
|
|
|
/* preclude from marking dir ordered */
|
|
|
|
fi->dir_ordered_count = 0;
|
2016-04-28 15:17:40 +08:00
|
|
|
} else if (ceph_frag_is_leftmost(frag) &&
|
|
|
|
fi->next_offset == 2) {
|
2015-06-16 20:48:56 +08:00
|
|
|
/* note dir version at start of readdir so
|
|
|
|
* we can tell if any dentries get dropped */
|
|
|
|
fi->dir_release_count = req->r_dir_release_cnt;
|
|
|
|
fi->dir_ordered_count = req->r_dir_ordered_cnt;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
dout("readdir !did_prepopulate");
|
|
|
|
/* disable readdir cache */
|
|
|
|
fi->readdir_cache_idx = -1;
|
|
|
|
/* preclude from marking dir complete */
|
|
|
|
fi->dir_release_count = 0;
|
|
|
|
}
|
|
|
|
|
2016-04-29 11:27:30 +08:00
|
|
|
/* note next offset and last dentry name */
|
|
|
|
if (rinfo->dir_nr > 0) {
|
2016-04-28 09:37:39 +08:00
|
|
|
struct ceph_mds_reply_dir_entry *rde =
|
|
|
|
rinfo->dir_entries + (rinfo->dir_nr-1);
|
2016-04-29 11:27:30 +08:00
|
|
|
unsigned next_offset = req->r_reply_info.dir_end ?
|
|
|
|
2 : (fpos_off(rde->offset) + 1);
|
2016-04-28 09:37:39 +08:00
|
|
|
err = note_last_dentry(fi, rde->name, rde->name_len,
|
2016-04-29 11:27:30 +08:00
|
|
|
next_offset);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
2016-04-29 11:27:30 +08:00
|
|
|
} else if (req->r_reply_info.dir_end) {
|
|
|
|
fi->next_offset = 2;
|
|
|
|
/* keep last name */
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rinfo = &fi->last_readdir->r_reply_info;
|
2016-04-28 15:17:40 +08:00
|
|
|
dout("readdir frag %x num %d pos %llx chunk first %llx\n",
|
2016-04-29 11:27:30 +08:00
|
|
|
fi->frag, rinfo->dir_nr, ctx->pos,
|
2016-04-28 15:17:40 +08:00
|
|
|
rinfo->dir_nr ? rinfo->dir_entries[0].offset : 0LL);
|
2013-05-18 04:52:26 +08:00
|
|
|
|
2016-04-28 15:17:40 +08:00
|
|
|
i = 0;
|
|
|
|
/* search start position */
|
|
|
|
if (rinfo->dir_nr > 0) {
|
|
|
|
int step, nr = rinfo->dir_nr;
|
|
|
|
while (nr > 0) {
|
|
|
|
step = nr >> 1;
|
|
|
|
if (rinfo->dir_entries[i + step].offset < ctx->pos) {
|
|
|
|
i += step + 1;
|
|
|
|
nr -= step + 1;
|
|
|
|
} else {
|
|
|
|
nr = step;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (; i < rinfo->dir_nr; i++) {
|
|
|
|
struct ceph_mds_reply_dir_entry *rde = rinfo->dir_entries + i;
|
2010-11-19 01:15:07 +08:00
|
|
|
struct ceph_vino vino;
|
|
|
|
ino_t ino;
|
|
|
|
|
2016-04-28 15:17:40 +08:00
|
|
|
BUG_ON(rde->offset < ctx->pos);
|
|
|
|
|
|
|
|
ctx->pos = rde->offset;
|
|
|
|
dout("readdir (%d/%d) -> %llx '%.*s' %p\n",
|
|
|
|
i, rinfo->dir_nr, ctx->pos,
|
2016-04-28 09:37:39 +08:00
|
|
|
rde->name_len, rde->name, &rde->inode.in);
|
2016-04-28 15:17:40 +08:00
|
|
|
|
2016-04-28 09:37:39 +08:00
|
|
|
BUG_ON(!rde->inode.in);
|
|
|
|
ftype = le32_to_cpu(rde->inode.in->mode) >> 12;
|
|
|
|
vino.ino = le64_to_cpu(rde->inode.in->ino);
|
|
|
|
vino.snap = le64_to_cpu(rde->inode.in->snapid);
|
2010-11-19 01:15:07 +08:00
|
|
|
ino = ceph_vino_to_ino(vino);
|
2016-04-28 15:17:40 +08:00
|
|
|
|
2016-04-28 09:37:39 +08:00
|
|
|
if (!dir_emit(ctx, rde->name, rde->name_len,
|
|
|
|
ceph_translate_ino(inode->i_sb, ino), ftype)) {
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
dout("filldir stopping us...\n");
|
|
|
|
return 0;
|
|
|
|
}
|
2013-05-18 04:52:26 +08:00
|
|
|
ctx->pos++;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
}
|
|
|
|
|
2016-04-29 11:27:30 +08:00
|
|
|
if (fi->next_offset > 2) {
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
ceph_mdsc_put_request(fi->last_readdir);
|
|
|
|
fi->last_readdir = NULL;
|
|
|
|
goto more;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* more frags? */
|
2016-04-29 11:27:30 +08:00
|
|
|
if (!ceph_frag_is_rightmost(fi->frag)) {
|
|
|
|
unsigned frag = ceph_frag_next(fi->frag);
|
|
|
|
if (is_hash_order(ctx->pos)) {
|
|
|
|
loff_t new_pos = ceph_make_fpos(ceph_frag_value(frag),
|
|
|
|
fi->next_offset, true);
|
|
|
|
if (new_pos > ctx->pos)
|
|
|
|
ctx->pos = new_pos;
|
|
|
|
/* keep last_name */
|
|
|
|
} else {
|
|
|
|
ctx->pos = ceph_make_fpos(frag, fi->next_offset, false);
|
|
|
|
kfree(fi->last_name);
|
|
|
|
fi->last_name = NULL;
|
|
|
|
}
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
dout("readdir next frag is %x\n", frag);
|
|
|
|
goto more;
|
|
|
|
}
|
2011-07-27 02:26:18 +08:00
|
|
|
fi->flags |= CEPH_F_ATEND;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* if dir_release_count still matches the dir, no dentries
|
|
|
|
* were released during the whole readdir, and we should have
|
|
|
|
* the complete dir contents in our cache.
|
|
|
|
*/
|
2015-06-16 20:48:56 +08:00
|
|
|
if (atomic64_read(&ci->i_release_count) == fi->dir_release_count) {
|
|
|
|
spin_lock(&ci->i_ceph_lock);
|
|
|
|
if (fi->dir_ordered_count == atomic64_read(&ci->i_ordered_count)) {
|
2014-10-22 09:09:56 +08:00
|
|
|
dout(" marking %p complete and ordered\n", inode);
|
2015-06-16 20:48:56 +08:00
|
|
|
/* use i_size to track number of entries in
|
|
|
|
* readdir cache */
|
|
|
|
BUG_ON(fi->readdir_cache_idx < 0);
|
|
|
|
i_size_write(inode, fi->readdir_cache_idx *
|
|
|
|
sizeof(struct dentry*));
|
|
|
|
} else {
|
2014-10-22 09:09:56 +08:00
|
|
|
dout(" marking %p complete\n", inode);
|
2015-06-16 20:48:56 +08:00
|
|
|
}
|
2014-10-22 09:09:56 +08:00
|
|
|
__ceph_dir_set_complete(ci, fi->dir_release_count,
|
|
|
|
fi->dir_ordered_count);
|
2015-06-16 20:48:56 +08:00
|
|
|
spin_unlock(&ci->i_ceph_lock);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
}
|
|
|
|
|
2013-05-18 04:52:26 +08:00
|
|
|
dout("readdir %p file %p done.\n", inode, file);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:17:40 +08:00
|
|
|
static void reset_readdir(struct ceph_file_info *fi)
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
{
|
|
|
|
if (fi->last_readdir) {
|
|
|
|
ceph_mdsc_put_request(fi->last_readdir);
|
|
|
|
fi->last_readdir = NULL;
|
|
|
|
}
|
|
|
|
kfree(fi->last_name);
|
2010-11-12 07:24:06 +08:00
|
|
|
fi->last_name = NULL;
|
2015-06-16 20:48:56 +08:00
|
|
|
fi->dir_release_count = 0;
|
|
|
|
fi->readdir_cache_idx = -1;
|
2016-04-27 17:32:34 +08:00
|
|
|
fi->next_offset = 2; /* compensate for . and .. */
|
2011-07-27 02:26:18 +08:00
|
|
|
fi->flags &= ~CEPH_F_ATEND;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
}
|
|
|
|
|
2016-04-28 15:17:40 +08:00
|
|
|
/*
|
|
|
|
* discard buffered readdir content on seekdir(0), or seek to new frag,
|
|
|
|
* or seek prior to current chunk
|
|
|
|
*/
|
|
|
|
static bool need_reset_readdir(struct ceph_file_info *fi, loff_t new_pos)
|
|
|
|
{
|
|
|
|
struct ceph_mds_reply_info_parsed *rinfo;
|
2016-04-29 11:27:30 +08:00
|
|
|
loff_t chunk_offset;
|
2016-04-28 15:17:40 +08:00
|
|
|
if (new_pos == 0)
|
|
|
|
return true;
|
2016-04-29 11:27:30 +08:00
|
|
|
if (is_hash_order(new_pos)) {
|
|
|
|
/* no need to reset last_name for a forward seek when
|
|
|
|
* dentries are sotred in hash order */
|
2016-08-29 00:47:12 +08:00
|
|
|
} else if (fi->frag != fpos_frag(new_pos)) {
|
2016-04-28 15:17:40 +08:00
|
|
|
return true;
|
2016-04-29 11:27:30 +08:00
|
|
|
}
|
2016-04-28 15:17:40 +08:00
|
|
|
rinfo = fi->last_readdir ? &fi->last_readdir->r_reply_info : NULL;
|
|
|
|
if (!rinfo || !rinfo->dir_nr)
|
|
|
|
return true;
|
2016-04-29 11:27:30 +08:00
|
|
|
chunk_offset = rinfo->dir_entries[0].offset;
|
|
|
|
return new_pos < chunk_offset ||
|
|
|
|
is_hash_order(new_pos) != is_hash_order(chunk_offset);
|
2016-04-28 15:17:40 +08:00
|
|
|
}
|
|
|
|
|
2012-12-18 07:59:39 +08:00
|
|
|
static loff_t ceph_dir_llseek(struct file *file, loff_t offset, int whence)
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
{
|
|
|
|
struct ceph_file_info *fi = file->private_data;
|
|
|
|
struct inode *inode = file->f_mapping->host;
|
|
|
|
loff_t retval;
|
|
|
|
|
2016-01-23 04:40:57 +08:00
|
|
|
inode_lock(inode);
|
2011-07-19 01:21:38 +08:00
|
|
|
retval = -EINVAL;
|
2012-12-18 07:59:39 +08:00
|
|
|
switch (whence) {
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
case SEEK_CUR:
|
|
|
|
offset += file->f_pos;
|
2011-07-19 01:21:38 +08:00
|
|
|
case SEEK_SET:
|
|
|
|
break;
|
2015-06-16 20:48:56 +08:00
|
|
|
case SEEK_END:
|
|
|
|
retval = -EOPNOTSUPP;
|
2011-07-19 01:21:38 +08:00
|
|
|
default:
|
|
|
|
goto out;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
}
|
2011-07-19 01:21:38 +08:00
|
|
|
|
2014-02-27 16:26:24 +08:00
|
|
|
if (offset >= 0) {
|
2016-04-29 11:27:30 +08:00
|
|
|
if (need_reset_readdir(fi, offset)) {
|
|
|
|
dout("dir_llseek dropping %p content\n", file);
|
|
|
|
reset_readdir(fi);
|
|
|
|
} else if (is_hash_order(offset) && offset > file->f_pos) {
|
|
|
|
/* for hash offset, we don't know if a forward seek
|
|
|
|
* is within same frag */
|
|
|
|
fi->dir_release_count = 0;
|
|
|
|
fi->readdir_cache_idx = -1;
|
|
|
|
}
|
|
|
|
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
if (offset != file->f_pos) {
|
|
|
|
file->f_pos = offset;
|
|
|
|
file->f_version = 0;
|
2011-07-27 02:26:18 +08:00
|
|
|
fi->flags &= ~CEPH_F_ATEND;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
}
|
|
|
|
retval = offset;
|
|
|
|
}
|
2011-07-19 01:21:38 +08:00
|
|
|
out:
|
2016-01-23 04:40:57 +08:00
|
|
|
inode_unlock(inode);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2011-07-27 02:28:11 +08:00
|
|
|
* Handle lookups for the hidden .snap directory.
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
*/
|
2011-07-27 02:28:11 +08:00
|
|
|
int ceph_handle_snapdir(struct ceph_mds_request *req,
|
|
|
|
struct dentry *dentry, int err)
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
{
|
2010-04-07 06:14:15 +08:00
|
|
|
struct ceph_fs_client *fsc = ceph_sb_to_client(dentry->d_sb);
|
2015-03-18 06:25:59 +08:00
|
|
|
struct inode *parent = d_inode(dentry->d_parent); /* we hold i_mutex */
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
|
|
|
|
/* .snap dir? */
|
|
|
|
if (err == -ENOENT &&
|
2011-03-04 05:44:35 +08:00
|
|
|
ceph_snap(parent) == CEPH_NOSNAP &&
|
2009-10-28 02:50:50 +08:00
|
|
|
strcmp(dentry->d_name.name,
|
2010-04-07 06:14:15 +08:00
|
|
|
fsc->mount_options->snapdir_name) == 0) {
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
struct inode *inode = ceph_get_snapdir(parent);
|
2014-10-22 08:11:25 +08:00
|
|
|
dout("ENOENT on snapdir %p '%pd', linking to snapdir %p\n",
|
|
|
|
dentry, dentry, inode);
|
2010-03-31 04:54:41 +08:00
|
|
|
BUG_ON(!d_unhashed(dentry));
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
d_add(dentry, inode);
|
|
|
|
err = 0;
|
|
|
|
}
|
2011-07-27 02:28:11 +08:00
|
|
|
return err;
|
|
|
|
}
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
|
2011-07-27 02:28:11 +08:00
|
|
|
/*
|
|
|
|
* Figure out final result of a lookup/open request.
|
|
|
|
*
|
|
|
|
* Mainly, make sure we return the final req->r_dentry (if it already
|
|
|
|
* existed) in place of the original VFS-provided dentry when they
|
|
|
|
* differ.
|
|
|
|
*
|
|
|
|
* Gracefully handle the case where the MDS replies with -ENOENT and
|
|
|
|
* no trace (which it may do, at its discretion, e.g., if it doesn't
|
|
|
|
* care to issue a lease on the negative dentry).
|
|
|
|
*/
|
|
|
|
struct dentry *ceph_finish_lookup(struct ceph_mds_request *req,
|
|
|
|
struct dentry *dentry, int err)
|
|
|
|
{
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
if (err == -ENOENT) {
|
|
|
|
/* no trace? */
|
|
|
|
err = 0;
|
|
|
|
if (!req->r_reply_info.head->is_dentry) {
|
|
|
|
dout("ENOENT and no trace, dentry %p inode %p\n",
|
2015-03-18 06:25:59 +08:00
|
|
|
dentry, d_inode(dentry));
|
|
|
|
if (d_really_is_positive(dentry)) {
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
d_drop(dentry);
|
|
|
|
err = -ENOENT;
|
|
|
|
} else {
|
|
|
|
d_add(dentry, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (err)
|
|
|
|
dentry = ERR_PTR(err);
|
|
|
|
else if (dentry != req->r_dentry)
|
|
|
|
dentry = dget(req->r_dentry); /* we got spliced */
|
|
|
|
else
|
|
|
|
dentry = NULL;
|
|
|
|
return dentry;
|
|
|
|
}
|
|
|
|
|
2016-03-25 17:18:39 +08:00
|
|
|
static bool is_root_ceph_dentry(struct inode *inode, struct dentry *dentry)
|
2009-12-03 03:54:25 +08:00
|
|
|
{
|
|
|
|
return ceph_ino(inode) == CEPH_INO_ROOT &&
|
|
|
|
strncmp(dentry->d_name.name, ".ceph", 5) == 0;
|
|
|
|
}
|
|
|
|
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
/*
|
|
|
|
* Look up a single dir entry. If there is a lookup intent, inform
|
|
|
|
* the MDS so that it gets our 'caps wanted' value in a single op.
|
|
|
|
*/
|
|
|
|
static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
|
2012-06-11 05:13:09 +08:00
|
|
|
unsigned int flags)
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
{
|
2010-04-07 06:14:15 +08:00
|
|
|
struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
|
|
|
|
struct ceph_mds_client *mdsc = fsc->mdsc;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
struct ceph_mds_request *req;
|
|
|
|
int op;
|
2016-03-07 10:34:50 +08:00
|
|
|
int mask;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
int err;
|
|
|
|
|
2014-10-22 08:11:25 +08:00
|
|
|
dout("lookup %p dentry %p '%pd'\n",
|
|
|
|
dir, dentry, dentry);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
|
|
|
|
if (dentry->d_name.len > NAME_MAX)
|
|
|
|
return ERR_PTR(-ENAMETOOLONG);
|
|
|
|
|
|
|
|
/* can we conclude ENOENT locally? */
|
2015-03-18 06:25:59 +08:00
|
|
|
if (d_really_is_negative(dentry)) {
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
struct ceph_inode_info *ci = ceph_inode(dir);
|
|
|
|
struct ceph_dentry_info *di = ceph_dentry(dentry);
|
|
|
|
|
2011-12-01 01:47:09 +08:00
|
|
|
spin_lock(&ci->i_ceph_lock);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
dout(" dir %p flags are %d\n", dir, ci->i_ceph_flags);
|
|
|
|
if (strncmp(dentry->d_name.name,
|
2010-04-07 06:14:15 +08:00
|
|
|
fsc->mount_options->snapdir_name,
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
dentry->d_name.len) &&
|
2009-12-03 03:54:25 +08:00
|
|
|
!is_root_ceph_dentry(dir, dentry) &&
|
2015-03-04 16:05:04 +08:00
|
|
|
ceph_test_mount_opt(fsc, DCACHE) &&
|
2013-03-13 19:44:32 +08:00
|
|
|
__ceph_dir_is_complete(ci) &&
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
(__ceph_caps_issued_mask(ci, CEPH_CAP_FILE_SHARED, 1))) {
|
2011-12-01 01:47:09 +08:00
|
|
|
spin_unlock(&ci->i_ceph_lock);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
dout(" dir %p complete, -ENOENT\n", dir);
|
|
|
|
d_add(dentry, NULL);
|
|
|
|
di->lease_shared_gen = ci->i_shared_gen;
|
|
|
|
return NULL;
|
|
|
|
}
|
2011-12-01 01:47:09 +08:00
|
|
|
spin_unlock(&ci->i_ceph_lock);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
op = ceph_snap(dir) == CEPH_SNAPDIR ?
|
|
|
|
CEPH_MDS_OP_LOOKUPSNAP : CEPH_MDS_OP_LOOKUP;
|
|
|
|
req = ceph_mdsc_create_request(mdsc, op, USE_ANY_MDS);
|
|
|
|
if (IS_ERR(req))
|
2010-05-22 18:01:14 +08:00
|
|
|
return ERR_CAST(req);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
req->r_dentry = dget(dentry);
|
|
|
|
req->r_num_caps = 2;
|
2016-03-07 10:34:50 +08:00
|
|
|
|
|
|
|
mask = CEPH_STAT_CAP_INODE | CEPH_CAP_AUTH_SHARED;
|
|
|
|
if (ceph_security_xattr_wanted(dir))
|
|
|
|
mask |= CEPH_CAP_XATTR_SHARED;
|
|
|
|
req->r_args.getattr.mask = cpu_to_le32(mask);
|
|
|
|
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
req->r_locked_dir = dir;
|
|
|
|
err = ceph_mdsc_do_request(mdsc, NULL, req);
|
2011-07-27 02:28:11 +08:00
|
|
|
err = ceph_handle_snapdir(req, dentry, err);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
dentry = ceph_finish_lookup(req, dentry, err);
|
|
|
|
ceph_mdsc_put_request(req); /* will dput(dentry) */
|
|
|
|
dout("lookup result=%p\n", dentry);
|
|
|
|
return dentry;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we do a create but get no trace back from the MDS, follow up with
|
|
|
|
* a lookup (the VFS expects us to link up the provided dentry).
|
|
|
|
*/
|
|
|
|
int ceph_handle_notrace_create(struct inode *dir, struct dentry *dentry)
|
|
|
|
{
|
2012-06-11 05:13:09 +08:00
|
|
|
struct dentry *result = ceph_lookup(dir, dentry, 0);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
|
|
|
|
if (result && !IS_ERR(result)) {
|
|
|
|
/*
|
|
|
|
* We created the item, then did a lookup, and found
|
|
|
|
* it was already linked to another inode we already
|
2015-02-04 15:10:48 +08:00
|
|
|
* had in our cache (and thus got spliced). To not
|
|
|
|
* confuse VFS (especially when inode is a directory),
|
|
|
|
* we don't link our dentry to that inode, return an
|
|
|
|
* error instead.
|
|
|
|
*
|
|
|
|
* This event should be rare and it happens only when
|
|
|
|
* we talk to old MDS. Recent MDS does not send traceless
|
|
|
|
* reply for request that creates new inode.
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
*/
|
2015-02-02 11:27:56 +08:00
|
|
|
d_drop(result);
|
2015-02-04 15:10:48 +08:00
|
|
|
return -ESTALE;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
}
|
|
|
|
return PTR_ERR(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ceph_mknod(struct inode *dir, struct dentry *dentry,
|
2011-07-26 13:52:52 +08:00
|
|
|
umode_t mode, dev_t rdev)
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
{
|
2010-04-07 06:14:15 +08:00
|
|
|
struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
|
|
|
|
struct ceph_mds_client *mdsc = fsc->mdsc;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
struct ceph_mds_request *req;
|
2014-09-16 20:35:17 +08:00
|
|
|
struct ceph_acls_info acls = {};
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
int err;
|
|
|
|
|
|
|
|
if (ceph_snap(dir) != CEPH_NOSNAP)
|
|
|
|
return -EROFS;
|
|
|
|
|
2014-09-16 20:35:17 +08:00
|
|
|
err = ceph_pre_init_acls(dir, &mode, &acls);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
|
2011-07-26 13:52:52 +08:00
|
|
|
dout("mknod in dir %p dentry %p mode 0%ho rdev %d\n",
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
dir, dentry, mode, rdev);
|
|
|
|
req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_MKNOD, USE_AUTH_MDS);
|
|
|
|
if (IS_ERR(req)) {
|
2014-09-16 20:35:17 +08:00
|
|
|
err = PTR_ERR(req);
|
|
|
|
goto out;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
}
|
|
|
|
req->r_dentry = dget(dentry);
|
|
|
|
req->r_num_caps = 2;
|
|
|
|
req->r_locked_dir = dir;
|
|
|
|
req->r_args.mknod.mode = cpu_to_le32(mode);
|
|
|
|
req->r_args.mknod.rdev = cpu_to_le32(rdev);
|
|
|
|
req->r_dentry_drop = CEPH_CAP_FILE_SHARED;
|
|
|
|
req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
|
2014-09-16 20:35:17 +08:00
|
|
|
if (acls.pagelist) {
|
|
|
|
req->r_pagelist = acls.pagelist;
|
|
|
|
acls.pagelist = NULL;
|
|
|
|
}
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
err = ceph_mdsc_do_request(mdsc, dir, req);
|
|
|
|
if (!err && !req->r_reply_info.head->is_dentry)
|
|
|
|
err = ceph_handle_notrace_create(dir, dentry);
|
|
|
|
ceph_mdsc_put_request(req);
|
2014-09-16 20:35:17 +08:00
|
|
|
out:
|
2013-11-11 15:18:03 +08:00
|
|
|
if (!err)
|
2015-03-18 06:25:59 +08:00
|
|
|
ceph_init_inode_acls(d_inode(dentry), &acls);
|
2014-02-11 12:55:05 +08:00
|
|
|
else
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
d_drop(dentry);
|
2014-09-16 20:35:17 +08:00
|
|
|
ceph_release_acls_info(&acls);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2011-07-26 13:42:34 +08:00
|
|
|
static int ceph_create(struct inode *dir, struct dentry *dentry, umode_t mode,
|
2012-06-11 06:05:36 +08:00
|
|
|
bool excl)
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
{
|
2012-06-05 21:10:25 +08:00
|
|
|
return ceph_mknod(dir, dentry, mode, 0);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ceph_symlink(struct inode *dir, struct dentry *dentry,
|
|
|
|
const char *dest)
|
|
|
|
{
|
2010-04-07 06:14:15 +08:00
|
|
|
struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
|
|
|
|
struct ceph_mds_client *mdsc = fsc->mdsc;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
struct ceph_mds_request *req;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (ceph_snap(dir) != CEPH_NOSNAP)
|
|
|
|
return -EROFS;
|
|
|
|
|
|
|
|
dout("symlink in dir %p dentry %p to '%s'\n", dir, dentry, dest);
|
|
|
|
req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_SYMLINK, USE_AUTH_MDS);
|
|
|
|
if (IS_ERR(req)) {
|
2014-09-16 20:35:17 +08:00
|
|
|
err = PTR_ERR(req);
|
|
|
|
goto out;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
}
|
2015-06-13 17:27:05 +08:00
|
|
|
req->r_path2 = kstrdup(dest, GFP_KERNEL);
|
2015-03-22 00:54:58 +08:00
|
|
|
if (!req->r_path2) {
|
|
|
|
err = -ENOMEM;
|
|
|
|
ceph_mdsc_put_request(req);
|
|
|
|
goto out;
|
|
|
|
}
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
req->r_locked_dir = dir;
|
2015-03-22 00:54:58 +08:00
|
|
|
req->r_dentry = dget(dentry);
|
|
|
|
req->r_num_caps = 2;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
req->r_dentry_drop = CEPH_CAP_FILE_SHARED;
|
|
|
|
req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
|
|
|
|
err = ceph_mdsc_do_request(mdsc, dir, req);
|
|
|
|
if (!err && !req->r_reply_info.head->is_dentry)
|
|
|
|
err = ceph_handle_notrace_create(dir, dentry);
|
|
|
|
ceph_mdsc_put_request(req);
|
2014-09-16 20:35:17 +08:00
|
|
|
out:
|
|
|
|
if (err)
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
d_drop(dentry);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2011-07-26 13:41:39 +08:00
|
|
|
static int ceph_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
{
|
2010-04-07 06:14:15 +08:00
|
|
|
struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
|
|
|
|
struct ceph_mds_client *mdsc = fsc->mdsc;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
struct ceph_mds_request *req;
|
2014-09-16 20:35:17 +08:00
|
|
|
struct ceph_acls_info acls = {};
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
int err = -EROFS;
|
|
|
|
int op;
|
|
|
|
|
|
|
|
if (ceph_snap(dir) == CEPH_SNAPDIR) {
|
|
|
|
/* mkdir .snap/foo is a MKSNAP */
|
|
|
|
op = CEPH_MDS_OP_MKSNAP;
|
2014-10-22 08:11:25 +08:00
|
|
|
dout("mksnap dir %p snap '%pd' dn %p\n", dir,
|
|
|
|
dentry, dentry);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
} else if (ceph_snap(dir) == CEPH_NOSNAP) {
|
2011-07-26 13:41:39 +08:00
|
|
|
dout("mkdir dir %p dn %p mode 0%ho\n", dir, dentry, mode);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
op = CEPH_MDS_OP_MKDIR;
|
|
|
|
} else {
|
|
|
|
goto out;
|
|
|
|
}
|
2014-09-16 20:35:17 +08:00
|
|
|
|
|
|
|
mode |= S_IFDIR;
|
|
|
|
err = ceph_pre_init_acls(dir, &mode, &acls);
|
|
|
|
if (err < 0)
|
|
|
|
goto out;
|
|
|
|
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
req = ceph_mdsc_create_request(mdsc, op, USE_AUTH_MDS);
|
|
|
|
if (IS_ERR(req)) {
|
|
|
|
err = PTR_ERR(req);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
req->r_dentry = dget(dentry);
|
|
|
|
req->r_num_caps = 2;
|
|
|
|
req->r_locked_dir = dir;
|
|
|
|
req->r_args.mkdir.mode = cpu_to_le32(mode);
|
|
|
|
req->r_dentry_drop = CEPH_CAP_FILE_SHARED;
|
|
|
|
req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
|
2014-09-16 20:35:17 +08:00
|
|
|
if (acls.pagelist) {
|
|
|
|
req->r_pagelist = acls.pagelist;
|
|
|
|
acls.pagelist = NULL;
|
|
|
|
}
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
err = ceph_mdsc_do_request(mdsc, dir, req);
|
2014-12-10 16:17:31 +08:00
|
|
|
if (!err &&
|
|
|
|
!req->r_reply_info.head->is_target &&
|
|
|
|
!req->r_reply_info.head->is_dentry)
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
err = ceph_handle_notrace_create(dir, dentry);
|
|
|
|
ceph_mdsc_put_request(req);
|
|
|
|
out:
|
2014-02-11 12:55:05 +08:00
|
|
|
if (!err)
|
2015-03-18 06:25:59 +08:00
|
|
|
ceph_init_inode_acls(d_inode(dentry), &acls);
|
2014-02-11 12:55:05 +08:00
|
|
|
else
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
d_drop(dentry);
|
2014-09-16 20:35:17 +08:00
|
|
|
ceph_release_acls_info(&acls);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ceph_link(struct dentry *old_dentry, struct inode *dir,
|
|
|
|
struct dentry *dentry)
|
|
|
|
{
|
2010-04-07 06:14:15 +08:00
|
|
|
struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
|
|
|
|
struct ceph_mds_client *mdsc = fsc->mdsc;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
struct ceph_mds_request *req;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (ceph_snap(dir) != CEPH_NOSNAP)
|
|
|
|
return -EROFS;
|
|
|
|
|
|
|
|
dout("link in dir %p old_dentry %p dentry %p\n", dir,
|
|
|
|
old_dentry, dentry);
|
|
|
|
req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_LINK, USE_AUTH_MDS);
|
|
|
|
if (IS_ERR(req)) {
|
|
|
|
d_drop(dentry);
|
|
|
|
return PTR_ERR(req);
|
|
|
|
}
|
|
|
|
req->r_dentry = dget(dentry);
|
|
|
|
req->r_num_caps = 2;
|
2013-02-06 05:41:23 +08:00
|
|
|
req->r_old_dentry = dget(old_dentry);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
req->r_locked_dir = dir;
|
|
|
|
req->r_dentry_drop = CEPH_CAP_FILE_SHARED;
|
|
|
|
req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
|
2013-07-21 20:25:25 +08:00
|
|
|
/* release LINK_SHARED on source inode (mds will lock it) */
|
|
|
|
req->r_old_inode_drop = CEPH_CAP_LINK_SHARED;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
err = ceph_mdsc_do_request(mdsc, dir, req);
|
2011-05-28 00:24:26 +08:00
|
|
|
if (err) {
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
d_drop(dentry);
|
2011-05-28 00:24:26 +08:00
|
|
|
} else if (!req->r_reply_info.head->is_dentry) {
|
2015-03-18 06:25:59 +08:00
|
|
|
ihold(d_inode(old_dentry));
|
|
|
|
d_instantiate(dentry, d_inode(old_dentry));
|
2011-05-28 00:24:26 +08:00
|
|
|
}
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
ceph_mdsc_put_request(req);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For a soon-to-be unlinked file, drop the AUTH_RDCACHE caps. If it
|
|
|
|
* looks like the link count will hit 0, drop any other caps (other
|
|
|
|
* than PIN) we don't specifically want (due to the file still being
|
|
|
|
* open).
|
|
|
|
*/
|
|
|
|
static int drop_caps_for_unlink(struct inode *inode)
|
|
|
|
{
|
|
|
|
struct ceph_inode_info *ci = ceph_inode(inode);
|
|
|
|
int drop = CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL;
|
|
|
|
|
2011-12-01 01:47:09 +08:00
|
|
|
spin_lock(&ci->i_ceph_lock);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
if (inode->i_nlink == 1) {
|
|
|
|
drop |= ~(__ceph_caps_wanted(ci) | CEPH_CAP_PIN);
|
|
|
|
ci->i_ceph_flags |= CEPH_I_NODELAY;
|
|
|
|
}
|
2011-12-01 01:47:09 +08:00
|
|
|
spin_unlock(&ci->i_ceph_lock);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
return drop;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* rmdir and unlink are differ only by the metadata op code
|
|
|
|
*/
|
|
|
|
static int ceph_unlink(struct inode *dir, struct dentry *dentry)
|
|
|
|
{
|
2010-04-07 06:14:15 +08:00
|
|
|
struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
|
|
|
|
struct ceph_mds_client *mdsc = fsc->mdsc;
|
2015-03-18 06:25:59 +08:00
|
|
|
struct inode *inode = d_inode(dentry);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
struct ceph_mds_request *req;
|
|
|
|
int err = -EROFS;
|
|
|
|
int op;
|
|
|
|
|
|
|
|
if (ceph_snap(dir) == CEPH_SNAPDIR) {
|
|
|
|
/* rmdir .snap/foo is RMSNAP */
|
2014-10-22 08:11:25 +08:00
|
|
|
dout("rmsnap dir %p '%pd' dn %p\n", dir, dentry, dentry);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
op = CEPH_MDS_OP_RMSNAP;
|
|
|
|
} else if (ceph_snap(dir) == CEPH_NOSNAP) {
|
|
|
|
dout("unlink/rmdir dir %p dn %p inode %p\n",
|
|
|
|
dir, dentry, inode);
|
VFS: (Scripted) Convert S_ISLNK/DIR/REG(dentry->d_inode) to d_is_*(dentry)
Convert the following where appropriate:
(1) S_ISLNK(dentry->d_inode) to d_is_symlink(dentry).
(2) S_ISREG(dentry->d_inode) to d_is_reg(dentry).
(3) S_ISDIR(dentry->d_inode) to d_is_dir(dentry). This is actually more
complicated than it appears as some calls should be converted to
d_can_lookup() instead. The difference is whether the directory in
question is a real dir with a ->lookup op or whether it's a fake dir with
a ->d_automount op.
In some circumstances, we can subsume checks for dentry->d_inode not being
NULL into this, provided we the code isn't in a filesystem that expects
d_inode to be NULL if the dirent really *is* negative (ie. if we're going to
use d_inode() rather than d_backing_inode() to get the inode pointer).
Note that the dentry type field may be set to something other than
DCACHE_MISS_TYPE when d_inode is NULL in the case of unionmount, where the VFS
manages the fall-through from a negative dentry to a lower layer. In such a
case, the dentry type of the negative union dentry is set to the same as the
type of the lower dentry.
However, if you know d_inode is not NULL at the call site, then you can use
the d_is_xxx() functions even in a filesystem.
There is one further complication: a 0,0 chardev dentry may be labelled
DCACHE_WHITEOUT_TYPE rather than DCACHE_SPECIAL_TYPE. Strictly, this was
intended for special directory entry types that don't have attached inodes.
The following perl+coccinelle script was used:
use strict;
my @callers;
open($fd, 'git grep -l \'S_IS[A-Z].*->d_inode\' |') ||
die "Can't grep for S_ISDIR and co. callers";
@callers = <$fd>;
close($fd);
unless (@callers) {
print "No matches\n";
exit(0);
}
my @cocci = (
'@@',
'expression E;',
'@@',
'',
'- S_ISLNK(E->d_inode->i_mode)',
'+ d_is_symlink(E)',
'',
'@@',
'expression E;',
'@@',
'',
'- S_ISDIR(E->d_inode->i_mode)',
'+ d_is_dir(E)',
'',
'@@',
'expression E;',
'@@',
'',
'- S_ISREG(E->d_inode->i_mode)',
'+ d_is_reg(E)' );
my $coccifile = "tmp.sp.cocci";
open($fd, ">$coccifile") || die $coccifile;
print($fd "$_\n") || die $coccifile foreach (@cocci);
close($fd);
foreach my $file (@callers) {
chomp $file;
print "Processing ", $file, "\n";
system("spatch", "--sp-file", $coccifile, $file, "--in-place", "--no-show-diff") == 0 ||
die "spatch failed";
}
[AV: overlayfs parts skipped]
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2015-01-29 20:02:35 +08:00
|
|
|
op = d_is_dir(dentry) ?
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
CEPH_MDS_OP_RMDIR : CEPH_MDS_OP_UNLINK;
|
|
|
|
} else
|
|
|
|
goto out;
|
|
|
|
req = ceph_mdsc_create_request(mdsc, op, USE_AUTH_MDS);
|
|
|
|
if (IS_ERR(req)) {
|
|
|
|
err = PTR_ERR(req);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
req->r_dentry = dget(dentry);
|
|
|
|
req->r_num_caps = 2;
|
|
|
|
req->r_locked_dir = dir;
|
|
|
|
req->r_dentry_drop = CEPH_CAP_FILE_SHARED;
|
|
|
|
req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
|
|
|
|
req->r_inode_drop = drop_caps_for_unlink(inode);
|
|
|
|
err = ceph_mdsc_do_request(mdsc, dir, req);
|
|
|
|
if (!err && !req->r_reply_info.head->is_dentry)
|
|
|
|
d_delete(dentry);
|
|
|
|
ceph_mdsc_put_request(req);
|
|
|
|
out:
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ceph_rename(struct inode *old_dir, struct dentry *old_dentry,
|
fs: make remaining filesystems use .rename2
This is trivial to do:
- add flags argument to foo_rename()
- check if flags is zero
- assign foo_rename() to .rename2 instead of .rename
This doesn't mean it's impossible to support RENAME_NOREPLACE for these
filesystems, but it is not trivial, like for local filesystems.
RENAME_NOREPLACE must guarantee atomicity (i.e. it shouldn't be possible
for a file to be created on one host while it is overwritten by rename on
another host).
Filesystems converted:
9p, afs, ceph, coda, ecryptfs, kernfs, lustre, ncpfs, nfs, ocfs2, orangefs.
After this, we can get rid of the duplicate interfaces for rename.
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: David Howells <dhowells@redhat.com> [AFS]
Acked-by: Mike Marshall <hubcap@omnibond.com>
Cc: Eric Van Hensbergen <ericvh@gmail.com>
Cc: Ilya Dryomov <idryomov@gmail.com>
Cc: Jan Harkes <jaharkes@cs.cmu.edu>
Cc: Tyler Hicks <tyhicks@canonical.com>
Cc: Oleg Drokin <oleg.drokin@intel.com>
Cc: Trond Myklebust <trond.myklebust@primarydata.com>
Cc: Mark Fasheh <mfasheh@suse.com>
2016-09-27 17:03:58 +08:00
|
|
|
struct inode *new_dir, struct dentry *new_dentry,
|
|
|
|
unsigned int flags)
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
{
|
2010-04-07 06:14:15 +08:00
|
|
|
struct ceph_fs_client *fsc = ceph_sb_to_client(old_dir->i_sb);
|
|
|
|
struct ceph_mds_client *mdsc = fsc->mdsc;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
struct ceph_mds_request *req;
|
2015-04-07 15:36:32 +08:00
|
|
|
int op = CEPH_MDS_OP_RENAME;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
int err;
|
|
|
|
|
fs: make remaining filesystems use .rename2
This is trivial to do:
- add flags argument to foo_rename()
- check if flags is zero
- assign foo_rename() to .rename2 instead of .rename
This doesn't mean it's impossible to support RENAME_NOREPLACE for these
filesystems, but it is not trivial, like for local filesystems.
RENAME_NOREPLACE must guarantee atomicity (i.e. it shouldn't be possible
for a file to be created on one host while it is overwritten by rename on
another host).
Filesystems converted:
9p, afs, ceph, coda, ecryptfs, kernfs, lustre, ncpfs, nfs, ocfs2, orangefs.
After this, we can get rid of the duplicate interfaces for rename.
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: David Howells <dhowells@redhat.com> [AFS]
Acked-by: Mike Marshall <hubcap@omnibond.com>
Cc: Eric Van Hensbergen <ericvh@gmail.com>
Cc: Ilya Dryomov <idryomov@gmail.com>
Cc: Jan Harkes <jaharkes@cs.cmu.edu>
Cc: Tyler Hicks <tyhicks@canonical.com>
Cc: Oleg Drokin <oleg.drokin@intel.com>
Cc: Trond Myklebust <trond.myklebust@primarydata.com>
Cc: Mark Fasheh <mfasheh@suse.com>
2016-09-27 17:03:58 +08:00
|
|
|
if (flags)
|
|
|
|
return -EINVAL;
|
|
|
|
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
if (ceph_snap(old_dir) != ceph_snap(new_dir))
|
|
|
|
return -EXDEV;
|
2015-04-07 15:36:32 +08:00
|
|
|
if (ceph_snap(old_dir) != CEPH_NOSNAP) {
|
|
|
|
if (old_dir == new_dir && ceph_snap(old_dir) == CEPH_SNAPDIR)
|
|
|
|
op = CEPH_MDS_OP_RENAMESNAP;
|
|
|
|
else
|
|
|
|
return -EROFS;
|
|
|
|
}
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
dout("rename dir %p dentry %p to dir %p dentry %p\n",
|
|
|
|
old_dir, old_dentry, new_dir, new_dentry);
|
2015-04-07 15:36:32 +08:00
|
|
|
req = ceph_mdsc_create_request(mdsc, op, USE_AUTH_MDS);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
if (IS_ERR(req))
|
|
|
|
return PTR_ERR(req);
|
2013-02-06 05:36:05 +08:00
|
|
|
ihold(old_dir);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
req->r_dentry = dget(new_dentry);
|
|
|
|
req->r_num_caps = 2;
|
|
|
|
req->r_old_dentry = dget(old_dentry);
|
2013-02-06 05:36:05 +08:00
|
|
|
req->r_old_dentry_dir = old_dir;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
req->r_locked_dir = new_dir;
|
|
|
|
req->r_old_dentry_drop = CEPH_CAP_FILE_SHARED;
|
|
|
|
req->r_old_dentry_unless = CEPH_CAP_FILE_EXCL;
|
|
|
|
req->r_dentry_drop = CEPH_CAP_FILE_SHARED;
|
|
|
|
req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
|
|
|
|
/* release LINK_RDCACHE on source inode (mds will lock it) */
|
|
|
|
req->r_old_inode_drop = CEPH_CAP_LINK_SHARED;
|
2015-03-18 06:25:59 +08:00
|
|
|
if (d_really_is_positive(new_dentry))
|
|
|
|
req->r_inode_drop = drop_caps_for_unlink(d_inode(new_dentry));
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
err = ceph_mdsc_do_request(mdsc, old_dir, req);
|
|
|
|
if (!err && !req->r_reply_info.head->is_dentry) {
|
|
|
|
/*
|
|
|
|
* Normally d_move() is done by fill_trace (called by
|
|
|
|
* do_request, above). If there is no trace, we need
|
|
|
|
* to do it here.
|
|
|
|
*/
|
2010-04-29 07:12:06 +08:00
|
|
|
|
2015-06-16 20:48:56 +08:00
|
|
|
/* d_move screws up sibling dentries' offsets */
|
|
|
|
ceph_dir_clear_complete(old_dir);
|
|
|
|
ceph_dir_clear_complete(new_dir);
|
|
|
|
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
d_move(old_dentry, new_dentry);
|
2010-04-29 07:12:06 +08:00
|
|
|
|
|
|
|
/* ensure target dentry is invalidated, despite
|
|
|
|
rehashing bug in vfs_rename_dir */
|
2010-05-15 00:35:38 +08:00
|
|
|
ceph_invalidate_dentry_lease(new_dentry);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
}
|
|
|
|
ceph_mdsc_put_request(req);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2010-05-15 00:35:38 +08:00
|
|
|
/*
|
|
|
|
* Ensure a dentry lease will no longer revalidate.
|
|
|
|
*/
|
|
|
|
void ceph_invalidate_dentry_lease(struct dentry *dentry)
|
|
|
|
{
|
|
|
|
spin_lock(&dentry->d_lock);
|
2016-06-22 22:35:04 +08:00
|
|
|
ceph_dentry(dentry)->time = jiffies;
|
2010-05-15 00:35:38 +08:00
|
|
|
ceph_dentry(dentry)->lease_shared_gen = 0;
|
|
|
|
spin_unlock(&dentry->d_lock);
|
|
|
|
}
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if dentry lease is valid. If not, delete the lease. Try to
|
|
|
|
* renew if the least is more than half up.
|
|
|
|
*/
|
2016-07-01 21:39:20 +08:00
|
|
|
static int dentry_lease_is_valid(struct dentry *dentry, unsigned int flags,
|
|
|
|
struct inode *dir)
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
{
|
|
|
|
struct ceph_dentry_info *di;
|
|
|
|
struct ceph_mds_session *s;
|
|
|
|
int valid = 0;
|
|
|
|
u32 gen;
|
|
|
|
unsigned long ttl;
|
|
|
|
struct ceph_mds_session *session = NULL;
|
|
|
|
u32 seq = 0;
|
|
|
|
|
|
|
|
spin_lock(&dentry->d_lock);
|
|
|
|
di = ceph_dentry(dentry);
|
2016-07-01 21:39:20 +08:00
|
|
|
if (di && di->lease_session) {
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
s = di->lease_session;
|
2012-01-13 09:48:10 +08:00
|
|
|
spin_lock(&s->s_gen_ttl_lock);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
gen = s->s_cap_gen;
|
|
|
|
ttl = s->s_cap_ttl;
|
2012-01-13 09:48:10 +08:00
|
|
|
spin_unlock(&s->s_gen_ttl_lock);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
|
|
|
|
if (di->lease_gen == gen &&
|
2016-06-22 22:35:04 +08:00
|
|
|
time_before(jiffies, di->time) &&
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
time_before(jiffies, ttl)) {
|
|
|
|
valid = 1;
|
|
|
|
if (di->lease_renew_after &&
|
|
|
|
time_after(jiffies, di->lease_renew_after)) {
|
2016-07-01 21:39:20 +08:00
|
|
|
/*
|
|
|
|
* We should renew. If we're in RCU walk mode
|
|
|
|
* though, we can't do that so just return
|
|
|
|
* -ECHILD.
|
|
|
|
*/
|
|
|
|
if (flags & LOOKUP_RCU) {
|
|
|
|
valid = -ECHILD;
|
|
|
|
} else {
|
|
|
|
session = ceph_get_mds_session(s);
|
|
|
|
seq = di->lease_seq;
|
|
|
|
di->lease_renew_after = 0;
|
|
|
|
di->lease_renew_from = jiffies;
|
|
|
|
}
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
spin_unlock(&dentry->d_lock);
|
|
|
|
|
|
|
|
if (session) {
|
|
|
|
ceph_mdsc_lease_send_msg(session, dir, dentry,
|
|
|
|
CEPH_MDS_LEASE_RENEW, seq);
|
|
|
|
ceph_put_mds_session(session);
|
|
|
|
}
|
|
|
|
dout("dentry_lease_is_valid - dentry %p = %d\n", dentry, valid);
|
|
|
|
return valid;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if directory-wide content lease/cap is valid.
|
|
|
|
*/
|
|
|
|
static int dir_lease_is_valid(struct inode *dir, struct dentry *dentry)
|
|
|
|
{
|
|
|
|
struct ceph_inode_info *ci = ceph_inode(dir);
|
|
|
|
struct ceph_dentry_info *di = ceph_dentry(dentry);
|
|
|
|
int valid = 0;
|
|
|
|
|
2011-12-01 01:47:09 +08:00
|
|
|
spin_lock(&ci->i_ceph_lock);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
if (ci->i_shared_gen == di->lease_shared_gen)
|
|
|
|
valid = __ceph_caps_issued_mask(ci, CEPH_CAP_FILE_SHARED, 1);
|
2011-12-01 01:47:09 +08:00
|
|
|
spin_unlock(&ci->i_ceph_lock);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
dout("dir_lease_is_valid dir %p v%u dentry %p v%u = %d\n",
|
|
|
|
dir, (unsigned)ci->i_shared_gen, dentry,
|
|
|
|
(unsigned)di->lease_shared_gen, valid);
|
|
|
|
return valid;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if cached dentry can be trusted.
|
|
|
|
*/
|
2012-06-11 04:03:43 +08:00
|
|
|
static int ceph_d_revalidate(struct dentry *dentry, unsigned int flags)
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
{
|
2011-07-27 02:30:43 +08:00
|
|
|
int valid = 0;
|
2016-03-16 16:40:23 +08:00
|
|
|
struct dentry *parent;
|
2011-01-07 14:49:57 +08:00
|
|
|
struct inode *dir;
|
|
|
|
|
2016-07-01 21:39:21 +08:00
|
|
|
if (flags & LOOKUP_RCU) {
|
|
|
|
parent = ACCESS_ONCE(dentry->d_parent);
|
|
|
|
dir = d_inode_rcu(parent);
|
|
|
|
if (!dir)
|
|
|
|
return -ECHILD;
|
|
|
|
} else {
|
|
|
|
parent = dget_parent(dentry);
|
|
|
|
dir = d_inode(parent);
|
|
|
|
}
|
2011-01-07 14:49:57 +08:00
|
|
|
|
2014-10-22 08:11:25 +08:00
|
|
|
dout("d_revalidate %p '%pd' inode %p offset %lld\n", dentry,
|
2015-03-18 06:25:59 +08:00
|
|
|
dentry, d_inode(dentry), ceph_dentry(dentry)->offset);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
|
|
|
|
/* always trust cached snapped dentries, snapdir dentry */
|
|
|
|
if (ceph_snap(dir) != CEPH_NOSNAP) {
|
2014-10-22 08:11:25 +08:00
|
|
|
dout("d_revalidate %p '%pd' inode %p is SNAPPED\n", dentry,
|
2015-03-18 06:25:59 +08:00
|
|
|
dentry, d_inode(dentry));
|
2011-07-27 02:30:43 +08:00
|
|
|
valid = 1;
|
2015-03-18 06:25:59 +08:00
|
|
|
} else if (d_really_is_positive(dentry) &&
|
|
|
|
ceph_snap(d_inode(dentry)) == CEPH_SNAPDIR) {
|
2011-07-27 02:30:43 +08:00
|
|
|
valid = 1;
|
2016-07-01 21:39:20 +08:00
|
|
|
} else {
|
|
|
|
valid = dentry_lease_is_valid(dentry, flags, dir);
|
|
|
|
if (valid == -ECHILD)
|
|
|
|
return valid;
|
|
|
|
if (valid || dir_lease_is_valid(dir, dentry)) {
|
|
|
|
if (d_really_is_positive(dentry))
|
|
|
|
valid = ceph_is_any_caps(d_inode(dentry));
|
|
|
|
else
|
|
|
|
valid = 1;
|
|
|
|
}
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
}
|
|
|
|
|
2016-03-17 14:41:59 +08:00
|
|
|
if (!valid) {
|
|
|
|
struct ceph_mds_client *mdsc =
|
|
|
|
ceph_sb_to_client(dir->i_sb)->mdsc;
|
|
|
|
struct ceph_mds_request *req;
|
|
|
|
int op, mask, err;
|
|
|
|
|
2016-07-01 21:39:21 +08:00
|
|
|
if (flags & LOOKUP_RCU)
|
|
|
|
return -ECHILD;
|
|
|
|
|
2016-03-17 14:41:59 +08:00
|
|
|
op = ceph_snap(dir) == CEPH_SNAPDIR ?
|
2016-12-01 04:56:46 +08:00
|
|
|
CEPH_MDS_OP_LOOKUPSNAP : CEPH_MDS_OP_GETATTR;
|
2016-03-17 14:41:59 +08:00
|
|
|
req = ceph_mdsc_create_request(mdsc, op, USE_ANY_MDS);
|
|
|
|
if (!IS_ERR(req)) {
|
|
|
|
req->r_dentry = dget(dentry);
|
2016-12-01 04:56:46 +08:00
|
|
|
req->r_num_caps = op == CEPH_MDS_OP_GETATTR ? 1 : 2;
|
2016-03-17 14:41:59 +08:00
|
|
|
|
|
|
|
mask = CEPH_STAT_CAP_INODE | CEPH_CAP_AUTH_SHARED;
|
|
|
|
if (ceph_security_xattr_wanted(dir))
|
|
|
|
mask |= CEPH_CAP_XATTR_SHARED;
|
|
|
|
req->r_args.getattr.mask = mask;
|
|
|
|
|
|
|
|
err = ceph_mdsc_do_request(mdsc, NULL, req);
|
2016-12-01 04:56:46 +08:00
|
|
|
switch (err) {
|
|
|
|
case 0:
|
|
|
|
if (d_really_is_positive(dentry) &&
|
|
|
|
d_inode(dentry) == req->r_target_inode)
|
|
|
|
valid = 1;
|
|
|
|
break;
|
|
|
|
case -ENOENT:
|
|
|
|
if (d_really_is_negative(dentry))
|
|
|
|
valid = 1;
|
|
|
|
/* Fallthrough */
|
|
|
|
default:
|
|
|
|
break;
|
2016-03-17 14:41:59 +08:00
|
|
|
}
|
|
|
|
ceph_mdsc_put_request(req);
|
|
|
|
dout("d_revalidate %p lookup result=%d\n",
|
|
|
|
dentry, err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-27 02:30:43 +08:00
|
|
|
dout("d_revalidate %p %s\n", dentry, valid ? "valid" : "invalid");
|
2013-11-30 12:47:41 +08:00
|
|
|
if (valid) {
|
2011-07-27 02:30:43 +08:00
|
|
|
ceph_dentry_lru_touch(dentry);
|
2013-11-30 12:47:41 +08:00
|
|
|
} else {
|
|
|
|
ceph_dir_clear_complete(dir);
|
|
|
|
}
|
2016-03-16 16:40:23 +08:00
|
|
|
|
2016-07-01 21:39:21 +08:00
|
|
|
if (!(flags & LOOKUP_RCU))
|
|
|
|
dput(parent);
|
2011-07-27 02:30:43 +08:00
|
|
|
return valid;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2011-03-16 05:57:41 +08:00
|
|
|
* Release our ceph_dentry_info.
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
*/
|
2011-03-16 05:57:41 +08:00
|
|
|
static void ceph_d_release(struct dentry *dentry)
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
{
|
|
|
|
struct ceph_dentry_info *di = ceph_dentry(dentry);
|
|
|
|
|
2011-03-16 05:57:41 +08:00
|
|
|
dout("d_release %p\n", dentry);
|
2011-11-12 01:48:53 +08:00
|
|
|
ceph_dentry_lru_del(dentry);
|
2016-07-01 21:39:20 +08:00
|
|
|
|
|
|
|
spin_lock(&dentry->d_lock);
|
|
|
|
dentry->d_fsdata = NULL;
|
|
|
|
spin_unlock(&dentry->d_lock);
|
|
|
|
|
2011-11-12 01:48:53 +08:00
|
|
|
if (di->lease_session)
|
|
|
|
ceph_put_mds_session(di->lease_session);
|
|
|
|
kmem_cache_free(ceph_dentry_cachep, di);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
}
|
|
|
|
|
2011-03-16 06:53:40 +08:00
|
|
|
/*
|
|
|
|
* When the VFS prunes a dentry from the cache, we need to clear the
|
|
|
|
* complete flag on the parent directory.
|
|
|
|
*
|
|
|
|
* Called under dentry->d_lock.
|
|
|
|
*/
|
|
|
|
static void ceph_d_prune(struct dentry *dentry)
|
|
|
|
{
|
2011-11-12 01:48:08 +08:00
|
|
|
dout("ceph_d_prune %p\n", dentry);
|
2011-03-16 06:53:40 +08:00
|
|
|
|
|
|
|
/* do we have a valid parent? */
|
2012-06-08 04:43:35 +08:00
|
|
|
if (IS_ROOT(dentry))
|
2011-03-16 06:53:40 +08:00
|
|
|
return;
|
|
|
|
|
2013-03-13 19:44:32 +08:00
|
|
|
/* if we are not hashed, we don't affect dir's completeness */
|
2011-03-16 06:53:40 +08:00
|
|
|
if (d_unhashed(dentry))
|
|
|
|
return;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
|
2016-10-29 09:52:50 +08:00
|
|
|
if (ceph_snap(d_inode(dentry->d_parent)) == CEPH_SNAPDIR)
|
|
|
|
return;
|
|
|
|
|
2011-03-16 06:53:40 +08:00
|
|
|
/*
|
|
|
|
* we hold d_lock, so d_parent is stable, and d_fsdata is never
|
|
|
|
* cleared until d_release
|
|
|
|
*/
|
2015-03-18 06:25:59 +08:00
|
|
|
ceph_dir_clear_complete(d_inode(dentry->d_parent));
|
2011-03-16 06:53:40 +08:00
|
|
|
}
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* read() on a dir. This weird interface hack only works if mounted
|
|
|
|
* with '-o dirstat'.
|
|
|
|
*/
|
|
|
|
static ssize_t ceph_read_dir(struct file *file, char __user *buf, size_t size,
|
|
|
|
loff_t *ppos)
|
|
|
|
{
|
|
|
|
struct ceph_file_info *cf = file->private_data;
|
2013-01-24 06:07:38 +08:00
|
|
|
struct inode *inode = file_inode(file);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
struct ceph_inode_info *ci = ceph_inode(inode);
|
|
|
|
int left;
|
2011-05-13 05:28:05 +08:00
|
|
|
const int bufsize = 1024;
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
|
2010-04-07 06:14:15 +08:00
|
|
|
if (!ceph_test_mount_opt(ceph_sb_to_client(inode->i_sb), DIRSTAT))
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
return -EISDIR;
|
|
|
|
|
|
|
|
if (!cf->dir_info) {
|
2015-06-13 17:27:05 +08:00
|
|
|
cf->dir_info = kmalloc(bufsize, GFP_KERNEL);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
if (!cf->dir_info)
|
|
|
|
return -ENOMEM;
|
|
|
|
cf->dir_info_len =
|
2011-05-13 05:28:05 +08:00
|
|
|
snprintf(cf->dir_info, bufsize,
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
"entries: %20lld\n"
|
|
|
|
" files: %20lld\n"
|
|
|
|
" subdirs: %20lld\n"
|
|
|
|
"rentries: %20lld\n"
|
|
|
|
" rfiles: %20lld\n"
|
|
|
|
" rsubdirs: %20lld\n"
|
|
|
|
"rbytes: %20lld\n"
|
|
|
|
"rctime: %10ld.%09ld\n",
|
|
|
|
ci->i_files + ci->i_subdirs,
|
|
|
|
ci->i_files,
|
|
|
|
ci->i_subdirs,
|
|
|
|
ci->i_rfiles + ci->i_rsubdirs,
|
|
|
|
ci->i_rfiles,
|
|
|
|
ci->i_rsubdirs,
|
|
|
|
ci->i_rbytes,
|
|
|
|
(long)ci->i_rctime.tv_sec,
|
|
|
|
(long)ci->i_rctime.tv_nsec);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*ppos >= cf->dir_info_len)
|
|
|
|
return 0;
|
|
|
|
size = min_t(unsigned, size, cf->dir_info_len-*ppos);
|
|
|
|
left = copy_to_user(buf, cf->dir_info + *ppos, size);
|
|
|
|
if (left == size)
|
|
|
|
return -EFAULT;
|
|
|
|
*ppos += (size - left);
|
|
|
|
return size - left;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We maintain a private dentry LRU.
|
|
|
|
*
|
|
|
|
* FIXME: this needs to be changed to a per-mds lru to be useful.
|
|
|
|
*/
|
|
|
|
void ceph_dentry_lru_add(struct dentry *dn)
|
|
|
|
{
|
|
|
|
struct ceph_dentry_info *di = ceph_dentry(dn);
|
|
|
|
struct ceph_mds_client *mdsc;
|
|
|
|
|
2014-10-22 08:11:25 +08:00
|
|
|
dout("dentry_lru_add %p %p '%pd'\n", di, dn, dn);
|
2011-11-12 01:48:53 +08:00
|
|
|
mdsc = ceph_sb_to_client(dn->d_sb)->mdsc;
|
|
|
|
spin_lock(&mdsc->dentry_lru_lock);
|
|
|
|
list_add_tail(&di->lru, &mdsc->dentry_lru);
|
|
|
|
mdsc->num_dentry++;
|
|
|
|
spin_unlock(&mdsc->dentry_lru_lock);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ceph_dentry_lru_touch(struct dentry *dn)
|
|
|
|
{
|
|
|
|
struct ceph_dentry_info *di = ceph_dentry(dn);
|
|
|
|
struct ceph_mds_client *mdsc;
|
|
|
|
|
2014-10-22 08:11:25 +08:00
|
|
|
dout("dentry_lru_touch %p %p '%pd' (offset %lld)\n", di, dn, dn,
|
|
|
|
di->offset);
|
2011-11-12 01:48:53 +08:00
|
|
|
mdsc = ceph_sb_to_client(dn->d_sb)->mdsc;
|
|
|
|
spin_lock(&mdsc->dentry_lru_lock);
|
|
|
|
list_move_tail(&di->lru, &mdsc->dentry_lru);
|
|
|
|
spin_unlock(&mdsc->dentry_lru_lock);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ceph_dentry_lru_del(struct dentry *dn)
|
|
|
|
{
|
|
|
|
struct ceph_dentry_info *di = ceph_dentry(dn);
|
|
|
|
struct ceph_mds_client *mdsc;
|
|
|
|
|
2014-10-22 08:11:25 +08:00
|
|
|
dout("dentry_lru_del %p %p '%pd'\n", di, dn, dn);
|
2011-11-12 01:48:53 +08:00
|
|
|
mdsc = ceph_sb_to_client(dn->d_sb)->mdsc;
|
|
|
|
spin_lock(&mdsc->dentry_lru_lock);
|
|
|
|
list_del_init(&di->lru);
|
|
|
|
mdsc->num_dentry--;
|
|
|
|
spin_unlock(&mdsc->dentry_lru_lock);
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
}
|
|
|
|
|
2010-11-17 03:14:34 +08:00
|
|
|
/*
|
|
|
|
* Return name hash for a given dentry. This is dependent on
|
|
|
|
* the parent directory's hash function.
|
|
|
|
*/
|
2011-07-27 02:30:55 +08:00
|
|
|
unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn)
|
2010-11-17 03:14:34 +08:00
|
|
|
{
|
|
|
|
struct ceph_inode_info *dci = ceph_inode(dir);
|
|
|
|
|
|
|
|
switch (dci->i_dir_layout.dl_dir_hash) {
|
|
|
|
case 0: /* for backward compat */
|
|
|
|
case CEPH_STR_HASH_LINUX:
|
|
|
|
return dn->d_name.hash;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return ceph_str_hash(dci->i_dir_layout.dl_dir_hash,
|
|
|
|
dn->d_name.name, dn->d_name.len);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
const struct file_operations ceph_dir_fops = {
|
|
|
|
.read = ceph_read_dir,
|
2013-05-18 04:52:26 +08:00
|
|
|
.iterate = ceph_readdir,
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
.llseek = ceph_dir_llseek,
|
|
|
|
.open = ceph_open,
|
|
|
|
.release = ceph_release,
|
|
|
|
.unlocked_ioctl = ceph_ioctl,
|
2015-05-27 11:19:34 +08:00
|
|
|
.fsync = ceph_fsync,
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
};
|
|
|
|
|
2015-01-14 13:46:04 +08:00
|
|
|
const struct file_operations ceph_snapdir_fops = {
|
|
|
|
.iterate = ceph_readdir,
|
|
|
|
.llseek = ceph_dir_llseek,
|
|
|
|
.open = ceph_open,
|
|
|
|
.release = ceph_release,
|
|
|
|
};
|
|
|
|
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
const struct inode_operations ceph_dir_iops = {
|
|
|
|
.lookup = ceph_lookup,
|
|
|
|
.permission = ceph_permission,
|
|
|
|
.getattr = ceph_getattr,
|
|
|
|
.setattr = ceph_setattr,
|
|
|
|
.listxattr = ceph_listxattr,
|
2013-11-11 15:18:03 +08:00
|
|
|
.get_acl = ceph_get_acl,
|
2014-01-29 22:22:25 +08:00
|
|
|
.set_acl = ceph_set_acl,
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
.mknod = ceph_mknod,
|
|
|
|
.symlink = ceph_symlink,
|
|
|
|
.mkdir = ceph_mkdir,
|
|
|
|
.link = ceph_link,
|
|
|
|
.unlink = ceph_unlink,
|
|
|
|
.rmdir = ceph_unlink,
|
|
|
|
.rename = ceph_rename,
|
|
|
|
.create = ceph_create,
|
2012-06-05 21:10:25 +08:00
|
|
|
.atomic_open = ceph_atomic_open,
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
};
|
|
|
|
|
2015-01-14 13:46:04 +08:00
|
|
|
const struct inode_operations ceph_snapdir_iops = {
|
|
|
|
.lookup = ceph_lookup,
|
|
|
|
.permission = ceph_permission,
|
|
|
|
.getattr = ceph_getattr,
|
|
|
|
.mkdir = ceph_mkdir,
|
|
|
|
.rmdir = ceph_unlink,
|
2015-04-07 15:36:32 +08:00
|
|
|
.rename = ceph_rename,
|
2015-01-14 13:46:04 +08:00
|
|
|
};
|
|
|
|
|
2010-08-04 01:25:30 +08:00
|
|
|
const struct dentry_operations ceph_dentry_ops = {
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
.d_revalidate = ceph_d_revalidate,
|
2011-03-16 05:57:41 +08:00
|
|
|
.d_release = ceph_d_release,
|
2011-03-16 06:53:40 +08:00
|
|
|
.d_prune = ceph_d_prune,
|
2016-10-29 10:05:13 +08:00
|
|
|
.d_init = ceph_d_init,
|
ceph: directory operations
Directory operations, including lookup, are defined here. We take
advantage of lookup intents when possible. For the most part, we just
need to build the proper requests for the metadata server(s) and
pass things off to the mds_client.
The results of most operations are normally incorporated into the
client's cache when the reply is parsed by ceph_fill_trace().
However, if the MDS replies without a trace (e.g., when retrying an
update after an MDS failure recovery), some operation-specific cleanup
may be needed.
We can validate cached dentries in two ways. A per-dentry lease may
be issued by the MDS, or a per-directory cap may be issued that acts
as a lease on the entire directory. In the latter case, a 'gen' value
is used to determine which dentries belong to the currently leased
directory contents.
We normally prepopulate the dcache and icache with readdir results.
This makes subsequent lookups and getattrs avoid any server
interaction. It also lets us satisfy readdir operation by peeking at
the dcache IFF we hold the per-directory cap/lease, previously
performed a readdir, and haven't dropped any of the resulting
dentries.
Signed-off-by: Sage Weil <sage@newdream.net>
2009-10-07 02:31:08 +08:00
|
|
|
};
|