aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/link.c
diff options
context:
space:
mode:
authorSteve French <smfrench@gmail.com>2012-09-18 19:20:31 -0400
committerSteve French <smfrench@gmail.com>2012-09-24 22:46:29 -0400
commitd6e906f1b571d15ff5778a049802f6ef6f70159a (patch)
tree25dd58336fed99bacea189a2fb632221a0d6f1aa /fs/cifs/link.c
parent35143eb5c2e3ae6c91b29144449d23f05f573796 (diff)
CIFS: Move hardlink to ops struct
Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org> Signed-off-by: Steve French <sfrench@us.ibm.com> Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs/link.c')
-rw-r--r--fs/cifs/link.c74
1 files changed, 44 insertions, 30 deletions
diff --git a/fs/cifs/link.c b/fs/cifs/link.c
index e6ce3b112875..51dc2fb6e854 100644
--- a/fs/cifs/link.c
+++ b/fs/cifs/link.c
@@ -391,72 +391,86 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode,
391{ 391{
392 int rc = -EACCES; 392 int rc = -EACCES;
393 unsigned int xid; 393 unsigned int xid;
394 char *fromName = NULL; 394 char *from_name = NULL;
395 char *toName = NULL; 395 char *to_name = NULL;
396 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 396 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
397 struct tcon_link *tlink; 397 struct tcon_link *tlink;
398 struct cifs_tcon *pTcon; 398 struct cifs_tcon *tcon;
399 struct TCP_Server_Info *server;
399 struct cifsInodeInfo *cifsInode; 400 struct cifsInodeInfo *cifsInode;
400 401
401 tlink = cifs_sb_tlink(cifs_sb); 402 tlink = cifs_sb_tlink(cifs_sb);
402 if (IS_ERR(tlink)) 403 if (IS_ERR(tlink))
403 return PTR_ERR(tlink); 404 return PTR_ERR(tlink);
404 pTcon = tlink_tcon(tlink); 405 tcon = tlink_tcon(tlink);
405 406
406 xid = get_xid(); 407 xid = get_xid();
407 408
408 fromName = build_path_from_dentry(old_file); 409 from_name = build_path_from_dentry(old_file);
409 toName = build_path_from_dentry(direntry); 410 to_name = build_path_from_dentry(direntry);
410 if ((fromName == NULL) || (toName == NULL)) { 411 if ((from_name == NULL) || (to_name == NULL)) {
411 rc = -ENOMEM; 412 rc = -ENOMEM;
412 goto cifs_hl_exit; 413 goto cifs_hl_exit;
413 } 414 }
414 415
415 if (pTcon->unix_ext) 416 if (tcon->unix_ext)
416 rc = CIFSUnixCreateHardLink(xid, pTcon, fromName, toName, 417 rc = CIFSUnixCreateHardLink(xid, tcon, from_name, to_name,
417 cifs_sb->local_nls, 418 cifs_sb->local_nls,
418 cifs_sb->mnt_cifs_flags & 419 cifs_sb->mnt_cifs_flags &
419 CIFS_MOUNT_MAP_SPECIAL_CHR); 420 CIFS_MOUNT_MAP_SPECIAL_CHR);
420 else { 421 else {
421 rc = CIFSCreateHardLink(xid, pTcon, fromName, toName, 422 server = tcon->ses->server;
422 cifs_sb->local_nls, 423 if (!server->ops->create_hardlink)
423 cifs_sb->mnt_cifs_flags & 424 return -ENOSYS;
424 CIFS_MOUNT_MAP_SPECIAL_CHR); 425 rc = server->ops->create_hardlink(xid, tcon, from_name, to_name,
426 cifs_sb);
425 if ((rc == -EIO) || (rc == -EINVAL)) 427 if ((rc == -EIO) || (rc == -EINVAL))
426 rc = -EOPNOTSUPP; 428 rc = -EOPNOTSUPP;
427 } 429 }
428 430
429 d_drop(direntry); /* force new lookup from server of target */ 431 d_drop(direntry); /* force new lookup from server of target */
430 432
431 /* if source file is cached (oplocked) revalidate will not go to server 433 /*
432 until the file is closed or oplock broken so update nlinks locally */ 434 * if source file is cached (oplocked) revalidate will not go to server
435 * until the file is closed or oplock broken so update nlinks locally
436 */
433 if (old_file->d_inode) { 437 if (old_file->d_inode) {
434 cifsInode = CIFS_I(old_file->d_inode); 438 cifsInode = CIFS_I(old_file->d_inode);
435 if (rc == 0) { 439 if (rc == 0) {
436 spin_lock(&old_file->d_inode->i_lock); 440 spin_lock(&old_file->d_inode->i_lock);
437 inc_nlink(old_file->d_inode); 441 inc_nlink(old_file->d_inode);
438 spin_unlock(&old_file->d_inode->i_lock); 442 spin_unlock(&old_file->d_inode->i_lock);
439/* BB should we make this contingent on superblock flag NOATIME? */ 443 /*
440/* old_file->d_inode->i_ctime = CURRENT_TIME;*/ 444 * BB should we make this contingent on superblock flag
441 /* parent dir timestamps will update from srv 445 * NOATIME?
442 within a second, would it really be worth it 446 */
443 to set the parent dir cifs inode time to zero 447 /* old_file->d_inode->i_ctime = CURRENT_TIME; */
444 to force revalidate (faster) for it too? */ 448 /*
449 * parent dir timestamps will update from srv within a
450 * second, would it really be worth it to set the parent
451 * dir cifs inode time to zero to force revalidate
452 * (faster) for it too?
453 */
445 } 454 }
446 /* if not oplocked will force revalidate to get info 455 /*
447 on source file from srv */ 456 * if not oplocked will force revalidate to get info on source
457 * file from srv
458 */
448 cifsInode->time = 0; 459 cifsInode->time = 0;
449 460
450 /* Will update parent dir timestamps from srv within a second. 461 /*
451 Would it really be worth it to set the parent dir (cifs 462 * Will update parent dir timestamps from srv within a second.
452 inode) time field to zero to force revalidate on parent 463 * Would it really be worth it to set the parent dir (cifs
453 directory faster ie 464 * inode) time field to zero to force revalidate on parent
454 CIFS_I(inode)->time = 0; */ 465 * directory faster ie
466 *
467 * CIFS_I(inode)->time = 0;
468 */
455 } 469 }
456 470
457cifs_hl_exit: 471cifs_hl_exit:
458 kfree(fromName); 472 kfree(from_name);
459 kfree(toName); 473 kfree(to_name);
460 free_xid(xid); 474 free_xid(xid);
461 cifs_put_tlink(tlink); 475 cifs_put_tlink(tlink);
462 return rc; 476 return rc;