2 * linux/mds/mds_reint.c
4 * Lustre Metadata Server (mds) reintegration routines
6 * Copyright (C) 2002 Cluster File Systems, Inc.
7 * author: Peter Braam <braam@clusterfs.com>
9 * This code is issued under the GNU General Public License.
10 * See the file COPYING in this distribution
14 // XXX - add transaction sequence numbers
18 #include <linux/version.h>
19 #include <linux/module.h>
21 #include <linux/stat.h>
22 #include <linux/locks.h>
23 #include <linux/ext2_fs.h>
24 #include <linux/quotaops.h>
25 #include <asm/unistd.h>
26 #include <asm/uaccess.h>
27 #include <linux/obd_support.h>
28 #include <linux/obd.h>
29 #include <linux/lustre_lib.h>
30 #include <linux/lustre_idl.h>
31 #include <linux/lustre_mds.h>
32 #include <linux/obd_class.h>
34 extern struct mds_request *mds_prep_req(int size, int opcode, int namelen, char *name, int tgtlen, char *tgt);
36 static int mds_reint_setattr(struct mds_update_record *rec, struct mds_request *req)
41 de = mds_fid2dentry(req->rq_obd, rec->ur_fid1, &mnt);
43 req->rq_rephdr->status = -ESTALE;
47 printk("mds_setattr: ino %ld\n", de->d_inode->i_ino);
48 req->rq_rephdr->status = notify_change(de, &rec->ur_iattr);
55 static int mds_reint_create(struct mds_update_record *rec,
56 struct mds_request *req)
59 int type = rec->ur_mode & S_IFMT;
61 struct dentry *dchild;
64 de = mds_fid2dentry(req->rq_obd, rec->ur_fid1, &mnt);
66 req->rq_rephdr->status = -ESTALE;
69 printk("mds_reint_create: ino %ld\n", de->d_inode->i_ino);
71 dchild = lookup_one_len(rec->ur_name, de, rec->ur_namelen);
74 printk(__FUNCTION__ "child lookup error %d\n", rc);
76 req->rq_rephdr->status = -ESTALE;
80 if (dchild->d_inode) {
81 printk(__FUNCTION__ "child exists (dir %ld, name %s\n",
82 de->d_inode->i_ino, rec->ur_name);
84 req->rq_rephdr->status = -ESTALE;
90 rc = vfs_create(de->d_inode, dchild, rec->ur_mode);
94 rc = vfs_mkdir(de->d_inode, dchild, rec->ur_mode);
101 int rdev = rec->ur_id;
102 rc = vfs_mknod(de->d_inode, dchild, rec->ur_mode, rdev);
106 req->rq_rephdr->status = rc;
114 typedef int (*mds_reinter)(struct mds_update_record *, struct mds_request*);
116 static mds_reinter reinters[REINT_MAX+1] = {
117 [REINT_SETATTR] mds_reint_setattr,
118 [REINT_CREATE] mds_reint_create
121 int mds_reint_rec(struct mds_update_record *rec, struct mds_request *req)
125 if (rec->ur_opcode < 0 || rec->ur_opcode > REINT_MAX) {
126 printk(__FUNCTION__ "opcode %d not valid\n",
131 rc = mds_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep,
132 &req->rq_replen, &req->rq_repbuf);
135 printk("mds: out of memory\n");
136 req->rq_status = -ENOMEM;
139 req->rq_rephdr->seqno = req->rq_reqhdr->seqno;
141 rc = reinters[rec->ur_opcode](rec, req);