1274dcf55SMike Marshall /* 2274dcf55SMike Marshall * (C) 2001 Clemson University and The University of Chicago 3274dcf55SMike Marshall * 4274dcf55SMike Marshall * See COPYING in top-level directory. 5274dcf55SMike Marshall */ 6274dcf55SMike Marshall 7274dcf55SMike Marshall /* 8274dcf55SMike Marshall * Linux VFS namei operations. 9274dcf55SMike Marshall */ 10274dcf55SMike Marshall 11274dcf55SMike Marshall #include "protocol.h" 12575e9461SMike Marshall #include "orangefs-kernel.h" 13274dcf55SMike Marshall 14274dcf55SMike Marshall /* 15274dcf55SMike Marshall * Get a newly allocated inode to go with a negative dentry. 16274dcf55SMike Marshall */ 178bb8aefdSYi Liu static int orangefs_create(struct inode *dir, 18274dcf55SMike Marshall struct dentry *dentry, 19274dcf55SMike Marshall umode_t mode, 20274dcf55SMike Marshall bool exclusive) 21274dcf55SMike Marshall { 228bb8aefdSYi Liu struct orangefs_inode_s *parent = ORANGEFS_I(dir); 238bb8aefdSYi Liu struct orangefs_kernel_op_s *new_op; 24274dcf55SMike Marshall struct inode *inode; 25274dcf55SMike Marshall int ret; 26274dcf55SMike Marshall 27*5253487eSMike Marshall gossip_debug(GOSSIP_NAME_DEBUG, "%s: %s\n", 28*5253487eSMike Marshall __func__, 29*5253487eSMike Marshall dentry->d_name.name); 30274dcf55SMike Marshall 318bb8aefdSYi Liu new_op = op_alloc(ORANGEFS_VFS_OP_CREATE); 32274dcf55SMike Marshall if (!new_op) 33274dcf55SMike Marshall return -ENOMEM; 34274dcf55SMike Marshall 35274dcf55SMike Marshall new_op->upcall.req.create.parent_refn = parent->refn; 36274dcf55SMike Marshall 37274dcf55SMike Marshall fill_default_sys_attrs(new_op->upcall.req.create.attributes, 388bb8aefdSYi Liu ORANGEFS_TYPE_METAFILE, mode); 39274dcf55SMike Marshall 40274dcf55SMike Marshall strncpy(new_op->upcall.req.create.d_name, 418bb8aefdSYi Liu dentry->d_name.name, ORANGEFS_NAME_LEN); 42274dcf55SMike Marshall 43274dcf55SMike Marshall ret = service_operation(new_op, __func__, get_interruptible_flag(dir)); 44274dcf55SMike Marshall 45274dcf55SMike Marshall gossip_debug(GOSSIP_NAME_DEBUG, 46*5253487eSMike Marshall "%s: %s: handle:%pU: fsid:%d: new_op:%p: ret:%d:\n", 47*5253487eSMike Marshall __func__, 48*5253487eSMike Marshall dentry->d_name.name, 49274dcf55SMike Marshall &new_op->downcall.resp.create.refn.khandle, 50*5253487eSMike Marshall new_op->downcall.resp.create.refn.fs_id, 51*5253487eSMike Marshall new_op, 52*5253487eSMike Marshall ret); 53274dcf55SMike Marshall 54*5253487eSMike Marshall if (ret < 0) 55274dcf55SMike Marshall goto out; 56274dcf55SMike Marshall 578bb8aefdSYi Liu inode = orangefs_new_inode(dir->i_sb, dir, S_IFREG | mode, 0, 58274dcf55SMike Marshall &new_op->downcall.resp.create.refn); 59274dcf55SMike Marshall if (IS_ERR(inode)) { 60*5253487eSMike Marshall gossip_err("%s: Failed to allocate inode for file :%s:\n", 61*5253487eSMike Marshall __func__, 62*5253487eSMike Marshall dentry->d_name.name); 63274dcf55SMike Marshall ret = PTR_ERR(inode); 64274dcf55SMike Marshall goto out; 65274dcf55SMike Marshall } 66274dcf55SMike Marshall 67274dcf55SMike Marshall gossip_debug(GOSSIP_NAME_DEBUG, 68*5253487eSMike Marshall "%s: Assigned inode :%pU: for file :%s:\n", 69*5253487eSMike Marshall __func__, 70*5253487eSMike Marshall get_khandle_from_ino(inode), 71*5253487eSMike Marshall dentry->d_name.name); 72274dcf55SMike Marshall 73274dcf55SMike Marshall d_instantiate(dentry, inode); 74274dcf55SMike Marshall unlock_new_inode(inode); 75274dcf55SMike Marshall 76274dcf55SMike Marshall gossip_debug(GOSSIP_NAME_DEBUG, 77*5253487eSMike Marshall "%s: dentry instantiated for %s\n", 78*5253487eSMike Marshall __func__, 79274dcf55SMike Marshall dentry->d_name.name); 80274dcf55SMike Marshall 81274dcf55SMike Marshall SetMtimeFlag(parent); 82274dcf55SMike Marshall dir->i_mtime = dir->i_ctime = current_fs_time(dir->i_sb); 83274dcf55SMike Marshall mark_inode_dirty_sync(dir); 84274dcf55SMike Marshall ret = 0; 85274dcf55SMike Marshall out: 86274dcf55SMike Marshall op_release(new_op); 87*5253487eSMike Marshall gossip_debug(GOSSIP_NAME_DEBUG, 88*5253487eSMike Marshall "%s: %s: returning %d\n", 89*5253487eSMike Marshall __func__, 90*5253487eSMike Marshall dentry->d_name.name, 91*5253487eSMike Marshall ret); 92274dcf55SMike Marshall return ret; 93274dcf55SMike Marshall } 94274dcf55SMike Marshall 95274dcf55SMike Marshall /* 96274dcf55SMike Marshall * Attempt to resolve an object name (dentry->d_name), parent handle, and 97274dcf55SMike Marshall * fsid into a handle for the object. 98274dcf55SMike Marshall */ 998bb8aefdSYi Liu static struct dentry *orangefs_lookup(struct inode *dir, struct dentry *dentry, 100274dcf55SMike Marshall unsigned int flags) 101274dcf55SMike Marshall { 1028bb8aefdSYi Liu struct orangefs_inode_s *parent = ORANGEFS_I(dir); 1038bb8aefdSYi Liu struct orangefs_kernel_op_s *new_op; 104274dcf55SMike Marshall struct inode *inode; 105274dcf55SMike Marshall struct dentry *res; 106274dcf55SMike Marshall int ret = -EINVAL; 107274dcf55SMike Marshall 108274dcf55SMike Marshall /* 109274dcf55SMike Marshall * in theory we could skip a lookup here (if the intent is to 110274dcf55SMike Marshall * create) in order to avoid a potentially failed lookup, but 111274dcf55SMike Marshall * leaving it in can skip a valid lookup and try to create a file 112274dcf55SMike Marshall * that already exists (e.g. the vfs already handles checking for 113274dcf55SMike Marshall * -EEXIST on O_EXCL opens, which is broken if we skip this lookup 114274dcf55SMike Marshall * in the create path) 115274dcf55SMike Marshall */ 116274dcf55SMike Marshall gossip_debug(GOSSIP_NAME_DEBUG, "%s called on %s\n", 117274dcf55SMike Marshall __func__, dentry->d_name.name); 118274dcf55SMike Marshall 1198bb8aefdSYi Liu if (dentry->d_name.len > (ORANGEFS_NAME_LEN - 1)) 120274dcf55SMike Marshall return ERR_PTR(-ENAMETOOLONG); 121274dcf55SMike Marshall 1228bb8aefdSYi Liu new_op = op_alloc(ORANGEFS_VFS_OP_LOOKUP); 123274dcf55SMike Marshall if (!new_op) 124274dcf55SMike Marshall return ERR_PTR(-ENOMEM); 125274dcf55SMike Marshall 1267cec28e9SMike Marshall new_op->upcall.req.lookup.sym_follow = ORANGEFS_LOOKUP_LINK_NO_FOLLOW; 127274dcf55SMike Marshall 128274dcf55SMike Marshall gossip_debug(GOSSIP_NAME_DEBUG, "%s:%s:%d using parent %pU\n", 129274dcf55SMike Marshall __FILE__, 130274dcf55SMike Marshall __func__, 131274dcf55SMike Marshall __LINE__, 132274dcf55SMike Marshall &parent->refn.khandle); 133274dcf55SMike Marshall new_op->upcall.req.lookup.parent_refn = parent->refn; 134274dcf55SMike Marshall 135274dcf55SMike Marshall strncpy(new_op->upcall.req.lookup.d_name, dentry->d_name.name, 1368bb8aefdSYi Liu ORANGEFS_NAME_LEN); 137274dcf55SMike Marshall 138274dcf55SMike Marshall gossip_debug(GOSSIP_NAME_DEBUG, 139274dcf55SMike Marshall "%s: doing lookup on %s under %pU,%d (follow=%s)\n", 140274dcf55SMike Marshall __func__, 141274dcf55SMike Marshall new_op->upcall.req.lookup.d_name, 142274dcf55SMike Marshall &new_op->upcall.req.lookup.parent_refn.khandle, 143274dcf55SMike Marshall new_op->upcall.req.lookup.parent_refn.fs_id, 144274dcf55SMike Marshall ((new_op->upcall.req.lookup.sym_follow == 1458bb8aefdSYi Liu ORANGEFS_LOOKUP_LINK_FOLLOW) ? "yes" : "no")); 146274dcf55SMike Marshall 147274dcf55SMike Marshall ret = service_operation(new_op, __func__, get_interruptible_flag(dir)); 148274dcf55SMike Marshall 149274dcf55SMike Marshall gossip_debug(GOSSIP_NAME_DEBUG, 150274dcf55SMike Marshall "Lookup Got %pU, fsid %d (ret=%d)\n", 151274dcf55SMike Marshall &new_op->downcall.resp.lookup.refn.khandle, 152274dcf55SMike Marshall new_op->downcall.resp.lookup.refn.fs_id, 153274dcf55SMike Marshall ret); 154274dcf55SMike Marshall 155274dcf55SMike Marshall if (ret < 0) { 156274dcf55SMike Marshall if (ret == -ENOENT) { 157274dcf55SMike Marshall /* 158274dcf55SMike Marshall * if no inode was found, add a negative dentry to 159274dcf55SMike Marshall * dcache anyway; if we don't, we don't hold expected 160274dcf55SMike Marshall * lookup semantics and we most noticeably break 161274dcf55SMike Marshall * during directory renames. 162274dcf55SMike Marshall * 163274dcf55SMike Marshall * however, if the operation failed or exited, do not 164274dcf55SMike Marshall * add the dentry (e.g. in the case that a touch is 165274dcf55SMike Marshall * issued on a file that already exists that was 166274dcf55SMike Marshall * interrupted during this lookup -- no need to add 167274dcf55SMike Marshall * another negative dentry for an existing file) 168274dcf55SMike Marshall */ 169274dcf55SMike Marshall 170274dcf55SMike Marshall gossip_debug(GOSSIP_NAME_DEBUG, 1718bb8aefdSYi Liu "orangefs_lookup: Adding *negative* dentry " 172274dcf55SMike Marshall "%p for %s\n", 173274dcf55SMike Marshall dentry, 174274dcf55SMike Marshall dentry->d_name.name); 175274dcf55SMike Marshall 176274dcf55SMike Marshall d_add(dentry, NULL); 177274dcf55SMike Marshall res = NULL; 178274dcf55SMike Marshall goto out; 179274dcf55SMike Marshall } 180274dcf55SMike Marshall 181274dcf55SMike Marshall /* must be a non-recoverable error */ 182274dcf55SMike Marshall res = ERR_PTR(ret); 183274dcf55SMike Marshall goto out; 184274dcf55SMike Marshall } 185274dcf55SMike Marshall 1868bb8aefdSYi Liu inode = orangefs_iget(dir->i_sb, &new_op->downcall.resp.lookup.refn); 187274dcf55SMike Marshall if (IS_ERR(inode)) { 188274dcf55SMike Marshall gossip_debug(GOSSIP_NAME_DEBUG, 189274dcf55SMike Marshall "error %ld from iget\n", PTR_ERR(inode)); 190274dcf55SMike Marshall res = ERR_CAST(inode); 191274dcf55SMike Marshall goto out; 192274dcf55SMike Marshall } 193274dcf55SMike Marshall 194274dcf55SMike Marshall gossip_debug(GOSSIP_NAME_DEBUG, 195274dcf55SMike Marshall "%s:%s:%d " 196274dcf55SMike Marshall "Found good inode [%lu] with count [%d]\n", 197274dcf55SMike Marshall __FILE__, 198274dcf55SMike Marshall __func__, 199274dcf55SMike Marshall __LINE__, 200274dcf55SMike Marshall inode->i_ino, 201274dcf55SMike Marshall (int)atomic_read(&inode->i_count)); 202274dcf55SMike Marshall 203274dcf55SMike Marshall /* update dentry/inode pair into dcache */ 204274dcf55SMike Marshall res = d_splice_alias(inode, dentry); 205274dcf55SMike Marshall 206274dcf55SMike Marshall gossip_debug(GOSSIP_NAME_DEBUG, 207274dcf55SMike Marshall "Lookup success (inode ct = %d)\n", 208274dcf55SMike Marshall (int)atomic_read(&inode->i_count)); 209274dcf55SMike Marshall out: 210274dcf55SMike Marshall op_release(new_op); 211274dcf55SMike Marshall return res; 212274dcf55SMike Marshall } 213274dcf55SMike Marshall 214274dcf55SMike Marshall /* return 0 on success; non-zero otherwise */ 2158bb8aefdSYi Liu static int orangefs_unlink(struct inode *dir, struct dentry *dentry) 216274dcf55SMike Marshall { 217274dcf55SMike Marshall struct inode *inode = dentry->d_inode; 2188bb8aefdSYi Liu struct orangefs_inode_s *parent = ORANGEFS_I(dir); 2198bb8aefdSYi Liu struct orangefs_kernel_op_s *new_op; 220274dcf55SMike Marshall int ret; 221274dcf55SMike Marshall 222274dcf55SMike Marshall gossip_debug(GOSSIP_NAME_DEBUG, 223274dcf55SMike Marshall "%s: called on %s\n" 224274dcf55SMike Marshall " (inode %pU): Parent is %pU | fs_id %d\n", 225274dcf55SMike Marshall __func__, 226274dcf55SMike Marshall dentry->d_name.name, 227274dcf55SMike Marshall get_khandle_from_ino(inode), 228274dcf55SMike Marshall &parent->refn.khandle, 229274dcf55SMike Marshall parent->refn.fs_id); 230274dcf55SMike Marshall 2318bb8aefdSYi Liu new_op = op_alloc(ORANGEFS_VFS_OP_REMOVE); 232274dcf55SMike Marshall if (!new_op) 233274dcf55SMike Marshall return -ENOMEM; 234274dcf55SMike Marshall 235274dcf55SMike Marshall new_op->upcall.req.remove.parent_refn = parent->refn; 236274dcf55SMike Marshall strncpy(new_op->upcall.req.remove.d_name, dentry->d_name.name, 2378bb8aefdSYi Liu ORANGEFS_NAME_LEN); 238274dcf55SMike Marshall 2398bb8aefdSYi Liu ret = service_operation(new_op, "orangefs_unlink", 240274dcf55SMike Marshall get_interruptible_flag(inode)); 241274dcf55SMike Marshall 242*5253487eSMike Marshall gossip_debug(GOSSIP_NAME_DEBUG, 243*5253487eSMike Marshall "%s: service_operation returned:%d:\n", 244*5253487eSMike Marshall __func__, 245*5253487eSMike Marshall ret); 246*5253487eSMike Marshall 247274dcf55SMike Marshall op_release(new_op); 248274dcf55SMike Marshall 249274dcf55SMike Marshall if (!ret) { 250274dcf55SMike Marshall drop_nlink(inode); 251274dcf55SMike Marshall 252274dcf55SMike Marshall SetMtimeFlag(parent); 253274dcf55SMike Marshall dir->i_mtime = dir->i_ctime = current_fs_time(dir->i_sb); 254274dcf55SMike Marshall mark_inode_dirty_sync(dir); 255274dcf55SMike Marshall } 256274dcf55SMike Marshall return ret; 257274dcf55SMike Marshall } 258274dcf55SMike Marshall 2598bb8aefdSYi Liu static int orangefs_symlink(struct inode *dir, 260274dcf55SMike Marshall struct dentry *dentry, 261274dcf55SMike Marshall const char *symname) 262274dcf55SMike Marshall { 2638bb8aefdSYi Liu struct orangefs_inode_s *parent = ORANGEFS_I(dir); 2648bb8aefdSYi Liu struct orangefs_kernel_op_s *new_op; 265274dcf55SMike Marshall struct inode *inode; 266274dcf55SMike Marshall int mode = 755; 267274dcf55SMike Marshall int ret; 268274dcf55SMike Marshall 269274dcf55SMike Marshall gossip_debug(GOSSIP_NAME_DEBUG, "%s: called\n", __func__); 270274dcf55SMike Marshall 271274dcf55SMike Marshall if (!symname) 272274dcf55SMike Marshall return -EINVAL; 273274dcf55SMike Marshall 2748bb8aefdSYi Liu new_op = op_alloc(ORANGEFS_VFS_OP_SYMLINK); 275274dcf55SMike Marshall if (!new_op) 276274dcf55SMike Marshall return -ENOMEM; 277274dcf55SMike Marshall 278274dcf55SMike Marshall new_op->upcall.req.sym.parent_refn = parent->refn; 279274dcf55SMike Marshall 280274dcf55SMike Marshall fill_default_sys_attrs(new_op->upcall.req.sym.attributes, 2818bb8aefdSYi Liu ORANGEFS_TYPE_SYMLINK, 282274dcf55SMike Marshall mode); 283274dcf55SMike Marshall 284274dcf55SMike Marshall strncpy(new_op->upcall.req.sym.entry_name, 285274dcf55SMike Marshall dentry->d_name.name, 2868bb8aefdSYi Liu ORANGEFS_NAME_LEN); 2878bb8aefdSYi Liu strncpy(new_op->upcall.req.sym.target, symname, ORANGEFS_NAME_LEN); 288274dcf55SMike Marshall 289274dcf55SMike Marshall ret = service_operation(new_op, __func__, get_interruptible_flag(dir)); 290274dcf55SMike Marshall 291274dcf55SMike Marshall gossip_debug(GOSSIP_NAME_DEBUG, 2928bb8aefdSYi Liu "Symlink Got ORANGEFS handle %pU on fsid %d (ret=%d)\n", 293274dcf55SMike Marshall &new_op->downcall.resp.sym.refn.khandle, 294274dcf55SMike Marshall new_op->downcall.resp.sym.refn.fs_id, ret); 295274dcf55SMike Marshall 296274dcf55SMike Marshall if (ret < 0) { 297274dcf55SMike Marshall gossip_debug(GOSSIP_NAME_DEBUG, 298274dcf55SMike Marshall "%s: failed with error code %d\n", 299274dcf55SMike Marshall __func__, ret); 300274dcf55SMike Marshall goto out; 301274dcf55SMike Marshall } 302274dcf55SMike Marshall 3038bb8aefdSYi Liu inode = orangefs_new_inode(dir->i_sb, dir, S_IFLNK | mode, 0, 304274dcf55SMike Marshall &new_op->downcall.resp.sym.refn); 305274dcf55SMike Marshall if (IS_ERR(inode)) { 306274dcf55SMike Marshall gossip_err 3078bb8aefdSYi Liu ("*** Failed to allocate orangefs symlink inode\n"); 308274dcf55SMike Marshall ret = PTR_ERR(inode); 309274dcf55SMike Marshall goto out; 310274dcf55SMike Marshall } 311274dcf55SMike Marshall 312274dcf55SMike Marshall gossip_debug(GOSSIP_NAME_DEBUG, 313274dcf55SMike Marshall "Assigned symlink inode new number of %pU\n", 314274dcf55SMike Marshall get_khandle_from_ino(inode)); 315274dcf55SMike Marshall 316274dcf55SMike Marshall d_instantiate(dentry, inode); 317274dcf55SMike Marshall unlock_new_inode(inode); 318274dcf55SMike Marshall 319274dcf55SMike Marshall gossip_debug(GOSSIP_NAME_DEBUG, 320274dcf55SMike Marshall "Inode (Symlink) %pU -> %s\n", 321274dcf55SMike Marshall get_khandle_from_ino(inode), 322274dcf55SMike Marshall dentry->d_name.name); 323274dcf55SMike Marshall 324274dcf55SMike Marshall SetMtimeFlag(parent); 325274dcf55SMike Marshall dir->i_mtime = dir->i_ctime = current_fs_time(dir->i_sb); 326274dcf55SMike Marshall mark_inode_dirty_sync(dir); 327274dcf55SMike Marshall ret = 0; 328274dcf55SMike Marshall out: 329274dcf55SMike Marshall op_release(new_op); 330274dcf55SMike Marshall return ret; 331274dcf55SMike Marshall } 332274dcf55SMike Marshall 3338bb8aefdSYi Liu static int orangefs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) 334274dcf55SMike Marshall { 3358bb8aefdSYi Liu struct orangefs_inode_s *parent = ORANGEFS_I(dir); 3368bb8aefdSYi Liu struct orangefs_kernel_op_s *new_op; 337274dcf55SMike Marshall struct inode *inode; 338274dcf55SMike Marshall int ret; 339274dcf55SMike Marshall 3408bb8aefdSYi Liu new_op = op_alloc(ORANGEFS_VFS_OP_MKDIR); 341274dcf55SMike Marshall if (!new_op) 342274dcf55SMike Marshall return -ENOMEM; 343274dcf55SMike Marshall 344274dcf55SMike Marshall new_op->upcall.req.mkdir.parent_refn = parent->refn; 345274dcf55SMike Marshall 346274dcf55SMike Marshall fill_default_sys_attrs(new_op->upcall.req.mkdir.attributes, 3478bb8aefdSYi Liu ORANGEFS_TYPE_DIRECTORY, mode); 348274dcf55SMike Marshall 349274dcf55SMike Marshall strncpy(new_op->upcall.req.mkdir.d_name, 3508bb8aefdSYi Liu dentry->d_name.name, ORANGEFS_NAME_LEN); 351274dcf55SMike Marshall 352274dcf55SMike Marshall ret = service_operation(new_op, __func__, get_interruptible_flag(dir)); 353274dcf55SMike Marshall 354274dcf55SMike Marshall gossip_debug(GOSSIP_NAME_DEBUG, 3558bb8aefdSYi Liu "Mkdir Got ORANGEFS handle %pU on fsid %d\n", 356274dcf55SMike Marshall &new_op->downcall.resp.mkdir.refn.khandle, 357274dcf55SMike Marshall new_op->downcall.resp.mkdir.refn.fs_id); 358274dcf55SMike Marshall 359274dcf55SMike Marshall if (ret < 0) { 360274dcf55SMike Marshall gossip_debug(GOSSIP_NAME_DEBUG, 361274dcf55SMike Marshall "%s: failed with error code %d\n", 362274dcf55SMike Marshall __func__, ret); 363274dcf55SMike Marshall goto out; 364274dcf55SMike Marshall } 365274dcf55SMike Marshall 3668bb8aefdSYi Liu inode = orangefs_new_inode(dir->i_sb, dir, S_IFDIR | mode, 0, 367274dcf55SMike Marshall &new_op->downcall.resp.mkdir.refn); 368274dcf55SMike Marshall if (IS_ERR(inode)) { 3698bb8aefdSYi Liu gossip_err("*** Failed to allocate orangefs dir inode\n"); 370274dcf55SMike Marshall ret = PTR_ERR(inode); 371274dcf55SMike Marshall goto out; 372274dcf55SMike Marshall } 373274dcf55SMike Marshall 374274dcf55SMike Marshall gossip_debug(GOSSIP_NAME_DEBUG, 375274dcf55SMike Marshall "Assigned dir inode new number of %pU\n", 376274dcf55SMike Marshall get_khandle_from_ino(inode)); 377274dcf55SMike Marshall 378274dcf55SMike Marshall d_instantiate(dentry, inode); 379274dcf55SMike Marshall unlock_new_inode(inode); 380274dcf55SMike Marshall 381274dcf55SMike Marshall gossip_debug(GOSSIP_NAME_DEBUG, 382274dcf55SMike Marshall "Inode (Directory) %pU -> %s\n", 383274dcf55SMike Marshall get_khandle_from_ino(inode), 384274dcf55SMike Marshall dentry->d_name.name); 385274dcf55SMike Marshall 386274dcf55SMike Marshall /* 387274dcf55SMike Marshall * NOTE: we have no good way to keep nlink consistent for directories 388274dcf55SMike Marshall * across clients; keep constant at 1. 389274dcf55SMike Marshall */ 390274dcf55SMike Marshall SetMtimeFlag(parent); 391274dcf55SMike Marshall dir->i_mtime = dir->i_ctime = current_fs_time(dir->i_sb); 392274dcf55SMike Marshall mark_inode_dirty_sync(dir); 393274dcf55SMike Marshall out: 394274dcf55SMike Marshall op_release(new_op); 395274dcf55SMike Marshall return ret; 396274dcf55SMike Marshall } 397274dcf55SMike Marshall 3988bb8aefdSYi Liu static int orangefs_rename(struct inode *old_dir, 399274dcf55SMike Marshall struct dentry *old_dentry, 400274dcf55SMike Marshall struct inode *new_dir, 401274dcf55SMike Marshall struct dentry *new_dentry) 402274dcf55SMike Marshall { 4038bb8aefdSYi Liu struct orangefs_kernel_op_s *new_op; 404274dcf55SMike Marshall int ret; 405274dcf55SMike Marshall 406274dcf55SMike Marshall gossip_debug(GOSSIP_NAME_DEBUG, 4078bb8aefdSYi Liu "orangefs_rename: called (%s/%s => %s/%s) ct=%d\n", 408274dcf55SMike Marshall old_dentry->d_parent->d_name.name, 409274dcf55SMike Marshall old_dentry->d_name.name, 410274dcf55SMike Marshall new_dentry->d_parent->d_name.name, 411274dcf55SMike Marshall new_dentry->d_name.name, 412274dcf55SMike Marshall d_count(new_dentry)); 413274dcf55SMike Marshall 4148bb8aefdSYi Liu new_op = op_alloc(ORANGEFS_VFS_OP_RENAME); 415274dcf55SMike Marshall if (!new_op) 416274dcf55SMike Marshall return -EINVAL; 417274dcf55SMike Marshall 4188bb8aefdSYi Liu new_op->upcall.req.rename.old_parent_refn = ORANGEFS_I(old_dir)->refn; 4198bb8aefdSYi Liu new_op->upcall.req.rename.new_parent_refn = ORANGEFS_I(new_dir)->refn; 420274dcf55SMike Marshall 421274dcf55SMike Marshall strncpy(new_op->upcall.req.rename.d_old_name, 422274dcf55SMike Marshall old_dentry->d_name.name, 4238bb8aefdSYi Liu ORANGEFS_NAME_LEN); 424274dcf55SMike Marshall strncpy(new_op->upcall.req.rename.d_new_name, 425274dcf55SMike Marshall new_dentry->d_name.name, 4268bb8aefdSYi Liu ORANGEFS_NAME_LEN); 427274dcf55SMike Marshall 428274dcf55SMike Marshall ret = service_operation(new_op, 4298bb8aefdSYi Liu "orangefs_rename", 430274dcf55SMike Marshall get_interruptible_flag(old_dentry->d_inode)); 431274dcf55SMike Marshall 432274dcf55SMike Marshall gossip_debug(GOSSIP_NAME_DEBUG, 4338bb8aefdSYi Liu "orangefs_rename: got downcall status %d\n", 434274dcf55SMike Marshall ret); 435274dcf55SMike Marshall 436274dcf55SMike Marshall if (new_dentry->d_inode) 437274dcf55SMike Marshall new_dentry->d_inode->i_ctime = CURRENT_TIME; 438274dcf55SMike Marshall 439274dcf55SMike Marshall op_release(new_op); 440274dcf55SMike Marshall return ret; 441274dcf55SMike Marshall } 442274dcf55SMike Marshall 4438bb8aefdSYi Liu /* ORANGEFS implementation of VFS inode operations for directories */ 4448bb8aefdSYi Liu struct inode_operations orangefs_dir_inode_operations = { 4458bb8aefdSYi Liu .lookup = orangefs_lookup, 4468bb8aefdSYi Liu .get_acl = orangefs_get_acl, 4478bb8aefdSYi Liu .set_acl = orangefs_set_acl, 4488bb8aefdSYi Liu .create = orangefs_create, 4498bb8aefdSYi Liu .unlink = orangefs_unlink, 4508bb8aefdSYi Liu .symlink = orangefs_symlink, 4518bb8aefdSYi Liu .mkdir = orangefs_mkdir, 4528bb8aefdSYi Liu .rmdir = orangefs_unlink, 4538bb8aefdSYi Liu .rename = orangefs_rename, 4548bb8aefdSYi Liu .setattr = orangefs_setattr, 4558bb8aefdSYi Liu .getattr = orangefs_getattr, 456274dcf55SMike Marshall .setxattr = generic_setxattr, 457274dcf55SMike Marshall .getxattr = generic_getxattr, 458274dcf55SMike Marshall .removexattr = generic_removexattr, 4598bb8aefdSYi Liu .listxattr = orangefs_listxattr, 460933287daSMartin Brandenburg .permission = orangefs_permission, 461274dcf55SMike Marshall }; 462