struct inode *search_inode_for_lustre(struct super_block *sb, const struct lu_fid *fid) { struct ll_sb_info *sbi = ll_s2sbi(sb); struct ptlrpc_request *req = NULL; struct inode *inode = NULL; int eadatalen = 0; unsigned long hash = cl_fid_build_ino(fid, ll_need_32bit_api(sbi)); struct md_op_data *op_data; int rc; CDEBUG(D_INFO, "searching inode for:(%lu,"DFID")\n", hash, PFID(fid)); inode = ilookup5(sb, hash, ll_nfs_test_inode, (void *)fid); if (inode) return inode; rc = ll_get_default_mdsize(sbi, &eadatalen); if (rc) return ERR_PTR(rc); /* Because inode is NULL, ll_prep_md_op_data can not * be used here. So we allocate op_data ourselves */ op_data = kzalloc(sizeof(*op_data), GFP_NOFS); if (!op_data) return ERR_PTR(-ENOMEM); op_data->op_fid1 = *fid; op_data->op_mode = eadatalen; op_data->op_valid = OBD_MD_FLEASIZE; /* mds_fid2dentry ignores f_type */ rc = md_getattr(sbi->ll_md_exp, op_data, &req); kfree(op_data); if (rc) { CERROR("can't get object attrs, fid "DFID", rc %d\n", PFID(fid), rc); return ERR_PTR(rc); } rc = ll_prep_inode(&inode, req, sb, NULL); ptlrpc_req_finished(req); if (rc) return ERR_PTR(rc); return inode; }
/** * The dispatch method tokenizes the input and passes it * on to the correct method which was invoked. */ int dispatch(char* str, int client) { FILE* stream = fdopen(client, "w"); char* cmd; cmd = strtok(str, "|"); // There was no command... if(cmd == NULL) return 0; if(strcmp(cmd, "readdir") == 0) { printf("'readdir' received\n"); md_readdir(stream, "/"); } else if(strcmp(cmd, "mknod") == 0) { printf("'mknod' received\n"); char* name = strtok(NULL, "|"); int mode = atoi(strtok(NULL, "|")); md_mknod(name, mode); } else if(strcmp(cmd, "unlink") == 0) { printf("'unlink' received\n"); char* name = strtok(NULL, "|"); md_unlink(name); } else if(strcmp(cmd, "truncate") == 0) { char* name = strtok(NULL, "|"); char* end; unsigned long long size = strtoull(strtok(NULL, "|"), &end, 10); printf("'truncate' '%s' '%llu' received\n", name, size); md_truncate(name, size); } else if(strcmp(cmd, "getattr") == 0) { char* name = strtok(NULL, "|"); printf("'getattr' '%s' received\n", name); md_getattr(stream, name); } else if(strcmp(cmd, "getobjects") == 0) { printf("'getobjects' received\n"); md_getobjects(stream); } else if(strcmp(cmd, "getfile") == 0) { printf("'getfile' received\n"); char* name = strtok(NULL, "|"); md_getfile(stream, name); } else if(strcmp(cmd, "chown") == 0) { printf("'chown' received\n"); char* name = strtok(NULL, "|"); uid_t uid = atoi(strtok(NULL, "|")); gid_t gid = atoi(strtok(NULL, "|")); md_chown(name, uid, gid); } else if(strcmp(cmd, "invalidate") == 0) { printf("'invalidate' received\n"); int file = atoi(strtok(NULL, "|")); int store = atoi(strtok(NULL, "|")); md_invalidate(file, store); } else if(strcmp(cmd, "getinvalid") == 0) { printf("'getinvalid' received\n"); char* hostname = strtok(NULL, "|"); int port = atoi(strtok(NULL, "|")); md_getinvalid(stream, hostname, port); } else if(strcmp(cmd, "setvalid") == 0) { printf("'setvalid' received\n"); int file = atoi(strtok(NULL, "|")); char* hostname = strtok(NULL, "|"); int port = atoi(strtok(NULL, "|")); md_setvalid(file, hostname, port); } return 0; }