diff options
author | Jeff Layton <jlayton@redhat.com> | 2010-09-17 17:31:30 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-09-17 17:31:30 -0400 |
commit | 779c51795bfb35c2403c924b9de90ca9356bc693 (patch) | |
tree | 6bdd2e6896425b58df4ec457c583a15af21cb0c4 /fs/nfs/dir.c | |
parent | e8582a8b96f329083b4da29aa87bc43cc0d80dd1 (diff) |
nfs: move nfs_sillyrename to unlink.c
...since that's where most of the sillyrenaming code lives. A comment
block is added to the beginning as well to clarify how sillyrenaming
works. Also, make nfs_async_unlink static as nfs_sillyrename is the only
caller.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/dir.c')
-rw-r--r-- | fs/nfs/dir.c | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 1e9e18813ad7..86f1d41c6078 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -1498,76 +1498,6 @@ static int nfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
1498 | return error; | 1498 | return error; |
1499 | } | 1499 | } |
1500 | 1500 | ||
1501 | static int nfs_sillyrename(struct inode *dir, struct dentry *dentry) | ||
1502 | { | ||
1503 | static unsigned int sillycounter; | ||
1504 | const int fileidsize = sizeof(NFS_FILEID(dentry->d_inode))*2; | ||
1505 | const int countersize = sizeof(sillycounter)*2; | ||
1506 | const int slen = sizeof(".nfs")+fileidsize+countersize-1; | ||
1507 | char silly[slen+1]; | ||
1508 | struct qstr qsilly; | ||
1509 | struct dentry *sdentry; | ||
1510 | int error = -EIO; | ||
1511 | |||
1512 | dfprintk(VFS, "NFS: silly-rename(%s/%s, ct=%d)\n", | ||
1513 | dentry->d_parent->d_name.name, dentry->d_name.name, | ||
1514 | atomic_read(&dentry->d_count)); | ||
1515 | nfs_inc_stats(dir, NFSIOS_SILLYRENAME); | ||
1516 | |||
1517 | /* | ||
1518 | * We don't allow a dentry to be silly-renamed twice. | ||
1519 | */ | ||
1520 | error = -EBUSY; | ||
1521 | if (dentry->d_flags & DCACHE_NFSFS_RENAMED) | ||
1522 | goto out; | ||
1523 | |||
1524 | sprintf(silly, ".nfs%*.*Lx", | ||
1525 | fileidsize, fileidsize, | ||
1526 | (unsigned long long)NFS_FILEID(dentry->d_inode)); | ||
1527 | |||
1528 | /* Return delegation in anticipation of the rename */ | ||
1529 | nfs_inode_return_delegation(dentry->d_inode); | ||
1530 | |||
1531 | sdentry = NULL; | ||
1532 | do { | ||
1533 | char *suffix = silly + slen - countersize; | ||
1534 | |||
1535 | dput(sdentry); | ||
1536 | sillycounter++; | ||
1537 | sprintf(suffix, "%*.*x", countersize, countersize, sillycounter); | ||
1538 | |||
1539 | dfprintk(VFS, "NFS: trying to rename %s to %s\n", | ||
1540 | dentry->d_name.name, silly); | ||
1541 | |||
1542 | sdentry = lookup_one_len(silly, dentry->d_parent, slen); | ||
1543 | /* | ||
1544 | * N.B. Better to return EBUSY here ... it could be | ||
1545 | * dangerous to delete the file while it's in use. | ||
1546 | */ | ||
1547 | if (IS_ERR(sdentry)) | ||
1548 | goto out; | ||
1549 | } while(sdentry->d_inode != NULL); /* need negative lookup */ | ||
1550 | |||
1551 | qsilly.name = silly; | ||
1552 | qsilly.len = strlen(silly); | ||
1553 | if (dentry->d_inode) { | ||
1554 | error = NFS_PROTO(dir)->rename(dir, &dentry->d_name, | ||
1555 | dir, &qsilly); | ||
1556 | nfs_mark_for_revalidate(dentry->d_inode); | ||
1557 | } else | ||
1558 | error = NFS_PROTO(dir)->rename(dir, &dentry->d_name, | ||
1559 | dir, &qsilly); | ||
1560 | if (!error) { | ||
1561 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | ||
1562 | d_move(dentry, sdentry); | ||
1563 | error = nfs_async_unlink(dir, dentry); | ||
1564 | /* If we return 0 we don't unlink */ | ||
1565 | } | ||
1566 | dput(sdentry); | ||
1567 | out: | ||
1568 | return error; | ||
1569 | } | ||
1570 | |||
1571 | /* | 1501 | /* |
1572 | * Remove a file after making sure there are no pending writes, | 1502 | * Remove a file after making sure there are no pending writes, |
1573 | * and after checking that the file has only one user. | 1503 | * and after checking that the file has only one user. |