- struct mds_client_info *mci;
-
- OBD_ALLOC(mci, sizeof(*mci));
- if (!mci) {
- CERROR("no memory for MDS client info\n");
- RETURN(-ENOMEM);
- }
- INIT_LIST_HEAD(&mci->mci_open_head);
-
- CDEBUG(D_INFO, "client at offset %d with UUID '%s' added\n",
- cl_off, mcd->mcd_uuid);
-
- if (cl_off == -1) {
- unsigned long *word;
- int bit;
-
- repeat:
- word = last_rcvd_slots;
- while(*word == ~0UL)
- ++word;
- if (word - last_rcvd_slots >= MDS_MAX_CLIENT_WORDS) {
- CERROR("no room in client MDS bitmap - fix code\n");
- return -ENOMEM;
- }
- bit = ffz(*word);
- if (test_and_set_bit(bit, word)) {
- CERROR("found bit %d set for word %d - fix code\n",
- bit, word - last_rcvd_slots);
- goto repeat;
- }
- cl_off = word - last_rcvd_slots + bit;
- } else {
- if (test_and_set_bit(cl_off, last_rcvd_slots)) {
- CERROR("bit %d already set in bitmap - bad bad\n",
- cl_off);
- LBUG();
- }
- }
-
- mci->mci_mcd = mcd;
- mci->mci_off = cl_off;
-
- /* For now we just put the clients in a list, not a hashed list */
- list_add_tail(&mci->mci_list, &mds->mds_client_info);
-
- mds->mds_client_count++;
-
- return 0;
-}
-
-void mds_client_del(struct mds_obd *mds, struct mds_client_info *mci)
-{
- unsigned long *word;
- int bit;
-
- word = last_rcvd_slots + mci->mci_off / sizeof(unsigned long);
- bit = mci->mci_off % sizeof(unsigned long);
-
- if (!test_and_clear_bit(bit, word)) {
- CERROR("bit %d already clear in word %d - bad bad\n",
- bit, word - last_rcvd_slots);
- LBUG();
- }
-
- --mds->mds_client_count;
- list_del(&mci->mci_list);
- OBD_FREE(mci->mci_mcd, sizeof(*mci->mci_mcd));
- OBD_FREE(mci, sizeof (*mci));
-}
-
-static int mds_client_free_all(struct mds_obd *mds)
-{
- struct list_head *p, *n;
-
- list_for_each_safe(p, n, &mds->mds_client_info) {
- struct mds_client_info *mci;
-
- mci = list_entry(p, struct mds_client_info, mci_list);
- mds_client_del(mds, mci);
- }
-
- return 0;
-}
-
-static int mds_server_free_data(struct mds_obd *mds)
-{
- OBD_FREE(mds->mds_server_data, sizeof(*mds->mds_server_data));
- mds->mds_server_data = NULL;
-
- return 0;
-}
-
-#define LAST_RCVD "last_rcvd"
-
-static int mds_read_last_rcvd(struct mds_obd *mds, struct file *f)
-{
- struct mds_server_data *msd;
- struct mds_client_data *mcd = NULL;
- loff_t fsize = f->f_dentry->d_inode->i_size;
- loff_t off = 0;
- int cl_off;
- __u64 last_rcvd = 0;
- __u64 last_mount;
- int rc = 0;
-
- OBD_ALLOC(msd, sizeof(*msd));
- if (!msd)
- RETURN(-ENOMEM);
- rc = lustre_fread(f, (char *)msd, sizeof(*msd), &off);
-
- mds->mds_server_data = msd;
- if (rc == 0) {
- CERROR("empty MDS %s, new MDS?\n", LAST_RCVD);
+ struct mds_obd *mds = &exp->exp_obd->u.mds;
+ struct inode *parent_inode = mds->mds_objects_dir->d_inode;
+ unsigned int tmpname = ll_rand();
+ struct file *filp;
+ struct dentry *new_child;
+ struct lvfs_run_ctxt saved;
+ char fidname[LL_FID_NAMELEN];
+ void *handle;
+ struct lvfs_ucred ucred = { 0 };
+ int rc = 0, err, namelen;
+ ENTRY;
+
+ /* the owner of object file should always be root */
+ cap_raise(ucred.luc_cap, CAP_SYS_RESOURCE);
+
+ if (strncmp(exp->exp_obd->obd_name, MDD_OBD_NAME,
+ strlen(MDD_OBD_NAME))) {