2 * Copryright (C) 2001 Cluster File Systems, Inc.
8 #include <linux/config.h>
9 #include <linux/module.h>
10 #include <linux/kernel.h>
12 #include <linux/string.h>
13 #include <linux/stat.h>
14 #include <linux/errno.h>
15 #include <linux/locks.h>
16 #include <linux/unistd.h>
18 #include <asm/system.h>
19 #include <asm/uaccess.h>
20 #include <linux/module.h>
23 #include <linux/stat.h>
24 #include <asm/uaccess.h>
25 #include <linux/vmalloc.h>
26 #include <asm/segment.h>
27 #include <linux/miscdevice.h>
29 #include <linux/obd_support.h>
30 #include <linux/lustre_lib.h>
31 #include <linux/lustre_idl.h>
32 #include <linux/lustre_mds.h>
34 extern int mdc_reint(struct lustre_peer *peer, struct ptlrpc_request *request);
35 extern struct ptlrpc_request *mds_prep_req(int opcode, int namelen, char *name, int tgtlen, char *tgt);
37 int mdc_setattr(struct lustre_peer *peer,
38 struct inode *inode, struct iattr *iattr,
39 struct mds_rep **rep, struct ptlrep_hdr **hdr)
42 struct ptlrpc_request *request;
43 struct mds_rec_setattr *rec;
45 request = mds_prep_req(MDS_REINT, 0, NULL, sizeof(*rec), NULL);
47 printk("mdc request: cannot pack\n");
51 rec = mds_req_tgt(request->rq_req.mds);
52 mds_setattr_pack(rec, inode, iattr);
53 request->rq_req.mds->opcode = HTON__u32(REINT_SETATTR);
55 sizeof(struct ptlrep_hdr) + sizeof(struct mds_rep);
57 rc = mdc_reint(peer, request);
62 *rep = request->rq_rep.mds;
65 *hdr = request->rq_rephdr;
71 int mdc_create(struct lustre_peer *peer,
72 struct inode *dir, const char *name, int namelen,
73 const char *tgt, int tgtlen,
74 int mode, __u64 id, __u32 uid, __u32 gid, __u64 time,
75 struct mds_rep **rep, struct ptlrep_hdr **hdr)
78 struct ptlrpc_request *request;
79 struct mds_rec_create *rec;
81 request = mds_prep_req(MDS_REINT, 0, NULL,
82 sizeof(*rec) + size_round0(namelen) +
83 size_round0(tgtlen), NULL);
85 printk("mdc_create: cannot pack\n");
90 sizeof(struct ptlrep_hdr) + sizeof(struct mds_rep);
92 rec = mds_req_tgt(request->rq_req.mds);
93 mds_create_pack(rec, dir, name, namelen, mode, id, uid, gid, time,
96 rc = mdc_reint(peer, request);
99 *rep = request->rq_rep.mds;
102 *hdr = request->rq_rephdr;
109 int mdc_unlink(struct lustre_peer *peer,
110 struct inode *dir, const char *name, int namelen,
111 struct mds_rep **rep, struct ptlrep_hdr **hdr)
114 struct ptlrpc_request *request;
115 struct mds_rec_unlink *rec;
117 request = mds_prep_req(MDS_REINT, 0, NULL,
118 sizeof(*rec) + size_round0(namelen), NULL);
120 printk("mdc_unlink: cannot pack\n");
125 sizeof(struct ptlrep_hdr) + sizeof(struct mds_rep);
127 rec = mds_req_tgt(request->rq_req.mds);
128 mds_unlink_pack(rec, dir, name, namelen);
130 rc = mdc_reint(peer, request);
133 *rep = request->rq_rep.mds;
136 *hdr = request->rq_rephdr;
143 int mdc_link(struct lustre_peer *peer, struct dentry *src,
144 struct inode *dir, const char *name, int namelen,
145 struct mds_rep **rep, struct ptlrep_hdr **hdr)
148 struct ptlrpc_request *request;
149 struct mds_rec_link *rec;
151 request = mds_prep_req(MDS_REINT, 0, NULL,
152 sizeof(*rec) + size_round0(namelen), NULL);
154 printk("mdc_link: cannot pack\n");
159 sizeof(struct ptlrep_hdr) + sizeof(struct mds_rep);
161 rec = mds_req_tgt(request->rq_req.mds);
162 mds_link_pack(rec, src->d_inode, dir, name, namelen);
164 rc = mdc_reint(peer, request);
167 *rep = request->rq_rep.mds;
170 *hdr = request->rq_rephdr;
177 int mdc_rename(struct lustre_peer *peer, struct inode *src,
178 struct inode *tgt, const char *old, int oldlen,
179 const char *new, int newlen,
180 struct mds_rep **rep, struct ptlrep_hdr **hdr)
183 struct ptlrpc_request *request;
184 struct mds_rec_rename *rec;
186 request = mds_prep_req(MDS_REINT, 0, NULL,
187 sizeof(*rec) + size_round0(oldlen)
188 + size_round0(newlen), NULL);
190 printk("mdc_link: cannot pack\n");
195 sizeof(struct ptlrep_hdr) + sizeof(struct mds_rep);
197 rec = mds_req_tgt(request->rq_req.mds);
198 mds_rename_pack(rec, src, tgt, old, oldlen, new, newlen);
200 rc = mdc_reint(peer, request);
203 *rep = request->rq_rep.mds;
206 *hdr = request->rq_rephdr;