aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph/dir.c
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@hq.newdream.net>2010-04-06 18:14:15 -0400
committerSage Weil <sage@newdream.net>2010-10-20 18:37:28 -0400
commit3d14c5d2b6e15c21d8e5467dc62d33127c23a644 (patch)
tree7d123c47847df9d1e865b6b78dc7da3fe739b704 /fs/ceph/dir.c
parentae1533b62b3369e6ae32338f4a77d64d0e88f676 (diff)
ceph: factor out libceph from Ceph file system
This factors out protocol and low-level storage parts of ceph into a separate libceph module living in net/ceph and include/linux/ceph. This is mostly a matter of moving files around. However, a few key pieces of the interface change as well: - ceph_client becomes ceph_fs_client and ceph_client, where the latter captures the mon and osd clients, and the fs_client gets the mds client and file system specific pieces. - Mount option parsing and debugfs setup is correspondingly broken into two pieces. - The mon client gets a generic handler callback for otherwise unknown messages (mds map, in this case). - The basic supported/required feature bits can be expanded (and are by ceph_fs_client). No functional change, aside from some subtle error handling cases that got cleaned up in the refactoring process. Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph/dir.c')
-rw-r--r--fs/ceph/dir.c55
1 files changed, 28 insertions, 27 deletions
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index a1986eb52045..a8d2aacc612b 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -1,4 +1,4 @@
1#include "ceph_debug.h" 1#include <linux/ceph/ceph_debug.h>
2 2
3#include <linux/spinlock.h> 3#include <linux/spinlock.h>
4#include <linux/fs_struct.h> 4#include <linux/fs_struct.h>
@@ -7,6 +7,7 @@
7#include <linux/sched.h> 7#include <linux/sched.h>
8 8
9#include "super.h" 9#include "super.h"
10#include "mds_client.h"
10 11
11/* 12/*
12 * Directory operations: readdir, lookup, create, link, unlink, 13 * Directory operations: readdir, lookup, create, link, unlink,
@@ -227,15 +228,15 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
227 struct ceph_file_info *fi = filp->private_data; 228 struct ceph_file_info *fi = filp->private_data;
228 struct inode *inode = filp->f_dentry->d_inode; 229 struct inode *inode = filp->f_dentry->d_inode;
229 struct ceph_inode_info *ci = ceph_inode(inode); 230 struct ceph_inode_info *ci = ceph_inode(inode);
230 struct ceph_client *client = ceph_inode_to_client(inode); 231 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
231 struct ceph_mds_client *mdsc = &client->mdsc; 232 struct ceph_mds_client *mdsc = fsc->mdsc;
232 unsigned frag = fpos_frag(filp->f_pos); 233 unsigned frag = fpos_frag(filp->f_pos);
233 int off = fpos_off(filp->f_pos); 234 int off = fpos_off(filp->f_pos);
234 int err; 235 int err;
235 u32 ftype; 236 u32 ftype;
236 struct ceph_mds_reply_info_parsed *rinfo; 237 struct ceph_mds_reply_info_parsed *rinfo;
237 const int max_entries = client->mount_args->max_readdir; 238 const int max_entries = fsc->mount_options->max_readdir;
238 const int max_bytes = client->mount_args->max_readdir_bytes; 239 const int max_bytes = fsc->mount_options->max_readdir_bytes;
239 240
240 dout("readdir %p filp %p frag %u off %u\n", inode, filp, frag, off); 241 dout("readdir %p filp %p frag %u off %u\n", inode, filp, frag, off);
241 if (fi->at_end) 242 if (fi->at_end)
@@ -267,7 +268,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
267 /* can we use the dcache? */ 268 /* can we use the dcache? */
268 spin_lock(&inode->i_lock); 269 spin_lock(&inode->i_lock);
269 if ((filp->f_pos == 2 || fi->dentry) && 270 if ((filp->f_pos == 2 || fi->dentry) &&
270 !ceph_test_opt(client, NOASYNCREADDIR) && 271 !ceph_test_mount_opt(fsc, NOASYNCREADDIR) &&
271 ceph_snap(inode) != CEPH_SNAPDIR && 272 ceph_snap(inode) != CEPH_SNAPDIR &&
272 (ci->i_ceph_flags & CEPH_I_COMPLETE) && 273 (ci->i_ceph_flags & CEPH_I_COMPLETE) &&
273 __ceph_caps_issued_mask(ci, CEPH_CAP_FILE_SHARED, 1)) { 274 __ceph_caps_issued_mask(ci, CEPH_CAP_FILE_SHARED, 1)) {
@@ -487,14 +488,14 @@ static loff_t ceph_dir_llseek(struct file *file, loff_t offset, int origin)
487struct dentry *ceph_finish_lookup(struct ceph_mds_request *req, 488struct dentry *ceph_finish_lookup(struct ceph_mds_request *req,
488 struct dentry *dentry, int err) 489 struct dentry *dentry, int err)
489{ 490{
490 struct ceph_client *client = ceph_sb_to_client(dentry->d_sb); 491 struct ceph_fs_client *fsc = ceph_sb_to_client(dentry->d_sb);
491 struct inode *parent = dentry->d_parent->d_inode; 492 struct inode *parent = dentry->d_parent->d_inode;
492 493
493 /* .snap dir? */ 494 /* .snap dir? */
494 if (err == -ENOENT && 495 if (err == -ENOENT &&
495 ceph_vino(parent).ino != CEPH_INO_ROOT && /* no .snap in root dir */ 496 ceph_vino(parent).ino != CEPH_INO_ROOT && /* no .snap in root dir */
496 strcmp(dentry->d_name.name, 497 strcmp(dentry->d_name.name,
497 client->mount_args->snapdir_name) == 0) { 498 fsc->mount_options->snapdir_name) == 0) {
498 struct inode *inode = ceph_get_snapdir(parent); 499 struct inode *inode = ceph_get_snapdir(parent);
499 dout("ENOENT on snapdir %p '%.*s', linking to snapdir %p\n", 500 dout("ENOENT on snapdir %p '%.*s', linking to snapdir %p\n",
500 dentry, dentry->d_name.len, dentry->d_name.name, inode); 501 dentry, dentry->d_name.len, dentry->d_name.name, inode);
@@ -539,8 +540,8 @@ static int is_root_ceph_dentry(struct inode *inode, struct dentry *dentry)
539static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry, 540static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
540 struct nameidata *nd) 541 struct nameidata *nd)
541{ 542{
542 struct ceph_client *client = ceph_sb_to_client(dir->i_sb); 543 struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
543 struct ceph_mds_client *mdsc = &client->mdsc; 544 struct ceph_mds_client *mdsc = fsc->mdsc;
544 struct ceph_mds_request *req; 545 struct ceph_mds_request *req;
545 int op; 546 int op;
546 int err; 547 int err;
@@ -572,7 +573,7 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
572 spin_lock(&dir->i_lock); 573 spin_lock(&dir->i_lock);
573 dout(" dir %p flags are %d\n", dir, ci->i_ceph_flags); 574 dout(" dir %p flags are %d\n", dir, ci->i_ceph_flags);
574 if (strncmp(dentry->d_name.name, 575 if (strncmp(dentry->d_name.name,
575 client->mount_args->snapdir_name, 576 fsc->mount_options->snapdir_name,
576 dentry->d_name.len) && 577 dentry->d_name.len) &&
577 !is_root_ceph_dentry(dir, dentry) && 578 !is_root_ceph_dentry(dir, dentry) &&
578 (ci->i_ceph_flags & CEPH_I_COMPLETE) && 579 (ci->i_ceph_flags & CEPH_I_COMPLETE) &&
@@ -629,8 +630,8 @@ int ceph_handle_notrace_create(struct inode *dir, struct dentry *dentry)
629static int ceph_mknod(struct inode *dir, struct dentry *dentry, 630static int ceph_mknod(struct inode *dir, struct dentry *dentry,
630 int mode, dev_t rdev) 631 int mode, dev_t rdev)
631{ 632{
632 struct ceph_client *client = ceph_sb_to_client(dir->i_sb); 633 struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
633 struct ceph_mds_client *mdsc = &client->mdsc; 634 struct ceph_mds_client *mdsc = fsc->mdsc;
634 struct ceph_mds_request *req; 635 struct ceph_mds_request *req;
635 int err; 636 int err;
636 637
@@ -685,8 +686,8 @@ static int ceph_create(struct inode *dir, struct dentry *dentry, int mode,
685static int ceph_symlink(struct inode *dir, struct dentry *dentry, 686static int ceph_symlink(struct inode *dir, struct dentry *dentry,
686 const char *dest) 687 const char *dest)
687{ 688{
688 struct ceph_client *client = ceph_sb_to_client(dir->i_sb); 689 struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
689 struct ceph_mds_client *mdsc = &client->mdsc; 690 struct ceph_mds_client *mdsc = fsc->mdsc;
690 struct ceph_mds_request *req; 691 struct ceph_mds_request *req;
691 int err; 692 int err;
692 693
@@ -716,8 +717,8 @@ static int ceph_symlink(struct inode *dir, struct dentry *dentry,
716 717
717static int ceph_mkdir(struct inode *dir, struct dentry *dentry, int mode) 718static int ceph_mkdir(struct inode *dir, struct dentry *dentry, int mode)
718{ 719{
719 struct ceph_client *client = ceph_sb_to_client(dir->i_sb); 720 struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
720 struct ceph_mds_client *mdsc = &client->mdsc; 721 struct ceph_mds_client *mdsc = fsc->mdsc;
721 struct ceph_mds_request *req; 722 struct ceph_mds_request *req;
722 int err = -EROFS; 723 int err = -EROFS;
723 int op; 724 int op;
@@ -758,8 +759,8 @@ out:
758static int ceph_link(struct dentry *old_dentry, struct inode *dir, 759static int ceph_link(struct dentry *old_dentry, struct inode *dir,
759 struct dentry *dentry) 760 struct dentry *dentry)
760{ 761{
761 struct ceph_client *client = ceph_sb_to_client(dir->i_sb); 762 struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
762 struct ceph_mds_client *mdsc = &client->mdsc; 763 struct ceph_mds_client *mdsc = fsc->mdsc;
763 struct ceph_mds_request *req; 764 struct ceph_mds_request *req;
764 int err; 765 int err;
765 766
@@ -813,8 +814,8 @@ static int drop_caps_for_unlink(struct inode *inode)
813 */ 814 */
814static int ceph_unlink(struct inode *dir, struct dentry *dentry) 815static int ceph_unlink(struct inode *dir, struct dentry *dentry)
815{ 816{
816 struct ceph_client *client = ceph_sb_to_client(dir->i_sb); 817 struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
817 struct ceph_mds_client *mdsc = &client->mdsc; 818 struct ceph_mds_client *mdsc = fsc->mdsc;
818 struct inode *inode = dentry->d_inode; 819 struct inode *inode = dentry->d_inode;
819 struct ceph_mds_request *req; 820 struct ceph_mds_request *req;
820 int err = -EROFS; 821 int err = -EROFS;
@@ -854,8 +855,8 @@ out:
854static int ceph_rename(struct inode *old_dir, struct dentry *old_dentry, 855static int ceph_rename(struct inode *old_dir, struct dentry *old_dentry,
855 struct inode *new_dir, struct dentry *new_dentry) 856 struct inode *new_dir, struct dentry *new_dentry)
856{ 857{
857 struct ceph_client *client = ceph_sb_to_client(old_dir->i_sb); 858 struct ceph_fs_client *fsc = ceph_sb_to_client(old_dir->i_sb);
858 struct ceph_mds_client *mdsc = &client->mdsc; 859 struct ceph_mds_client *mdsc = fsc->mdsc;
859 struct ceph_mds_request *req; 860 struct ceph_mds_request *req;
860 int err; 861 int err;
861 862
@@ -1076,7 +1077,7 @@ static ssize_t ceph_read_dir(struct file *file, char __user *buf, size_t size,
1076 struct ceph_inode_info *ci = ceph_inode(inode); 1077 struct ceph_inode_info *ci = ceph_inode(inode);
1077 int left; 1078 int left;
1078 1079
1079 if (!ceph_test_opt(ceph_sb_to_client(inode->i_sb), DIRSTAT)) 1080 if (!ceph_test_mount_opt(ceph_sb_to_client(inode->i_sb), DIRSTAT))
1080 return -EISDIR; 1081 return -EISDIR;
1081 1082
1082 if (!cf->dir_info) { 1083 if (!cf->dir_info) {
@@ -1177,7 +1178,7 @@ void ceph_dentry_lru_add(struct dentry *dn)
1177 dout("dentry_lru_add %p %p '%.*s'\n", di, dn, 1178 dout("dentry_lru_add %p %p '%.*s'\n", di, dn,
1178 dn->d_name.len, dn->d_name.name); 1179 dn->d_name.len, dn->d_name.name);
1179 if (di) { 1180 if (di) {
1180 mdsc = &ceph_sb_to_client(dn->d_sb)->mdsc; 1181 mdsc = ceph_sb_to_client(dn->d_sb)->mdsc;
1181 spin_lock(&mdsc->dentry_lru_lock); 1182 spin_lock(&mdsc->dentry_lru_lock);
1182 list_add_tail(&di->lru, &mdsc->dentry_lru); 1183 list_add_tail(&di->lru, &mdsc->dentry_lru);
1183 mdsc->num_dentry++; 1184 mdsc->num_dentry++;
@@ -1193,7 +1194,7 @@ void ceph_dentry_lru_touch(struct dentry *dn)
1193 dout("dentry_lru_touch %p %p '%.*s' (offset %lld)\n", di, dn, 1194 dout("dentry_lru_touch %p %p '%.*s' (offset %lld)\n", di, dn,
1194 dn->d_name.len, dn->d_name.name, di->offset); 1195 dn->d_name.len, dn->d_name.name, di->offset);
1195 if (di) { 1196 if (di) {
1196 mdsc = &ceph_sb_to_client(dn->d_sb)->mdsc; 1197 mdsc = ceph_sb_to_client(dn->d_sb)->mdsc;
1197 spin_lock(&mdsc->dentry_lru_lock); 1198 spin_lock(&mdsc->dentry_lru_lock);
1198 list_move_tail(&di->lru, &mdsc->dentry_lru); 1199 list_move_tail(&di->lru, &mdsc->dentry_lru);
1199 spin_unlock(&mdsc->dentry_lru_lock); 1200 spin_unlock(&mdsc->dentry_lru_lock);
@@ -1208,7 +1209,7 @@ void ceph_dentry_lru_del(struct dentry *dn)
1208 dout("dentry_lru_del %p %p '%.*s'\n", di, dn, 1209 dout("dentry_lru_del %p %p '%.*s'\n", di, dn,
1209 dn->d_name.len, dn->d_name.name); 1210 dn->d_name.len, dn->d_name.name);
1210 if (di) { 1211 if (di) {
1211 mdsc = &ceph_sb_to_client(dn->d_sb)->mdsc; 1212 mdsc = ceph_sb_to_client(dn->d_sb)->mdsc;
1212 spin_lock(&mdsc->dentry_lru_lock); 1213 spin_lock(&mdsc->dentry_lru_lock);
1213 list_del_init(&di->lru); 1214 list_del_init(&di->lru);
1214 mdsc->num_dentry--; 1215 mdsc->num_dentry--;