You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
vfs: push dentry_unhash on rename_dir into file systems
Only a few file systems need this. Start by pushing it down into each rename method (except gfs2 and xfs) so that it can be dealt with on a per-fs basis. Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Sage Weil <sage@newdream.net> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
@@ -840,6 +840,9 @@ v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
||||
struct p9_fid *newdirfid;
|
||||
struct p9_wstat wstat;
|
||||
|
||||
if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode))
|
||||
dentry_unhash(new_dentry);
|
||||
|
||||
P9_DPRINTK(P9_DEBUG_VFS, "\n");
|
||||
retval = 0;
|
||||
old_inode = old_dentry->d_inode;
|
||||
|
||||
@@ -419,6 +419,9 @@ affs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
||||
struct buffer_head *bh = NULL;
|
||||
int retval;
|
||||
|
||||
if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode))
|
||||
dentry_unhash(new_dentry);
|
||||
|
||||
pr_debug("AFFS: rename(old=%u,\"%*s\" to new=%u,\"%*s\")\n",
|
||||
(u32)old_dir->i_ino, (int)old_dentry->d_name.len, old_dentry->d_name.name,
|
||||
(u32)new_dir->i_ino, (int)new_dentry->d_name.len, new_dentry->d_name.name);
|
||||
|
||||
@@ -1148,6 +1148,9 @@ static int afs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
||||
struct key *key;
|
||||
int ret;
|
||||
|
||||
if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode))
|
||||
dentry_unhash(new_dentry);
|
||||
|
||||
vnode = AFS_FS_I(old_dentry->d_inode);
|
||||
orig_dvnode = AFS_FS_I(old_dir);
|
||||
new_dvnode = AFS_FS_I(new_dir);
|
||||
|
||||
@@ -224,6 +224,9 @@ static int bfs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
||||
struct bfs_sb_info *info;
|
||||
int error = -ENOENT;
|
||||
|
||||
if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode))
|
||||
dentry_unhash(new_dentry);
|
||||
|
||||
old_bh = new_bh = NULL;
|
||||
old_inode = old_dentry->d_inode;
|
||||
if (S_ISDIR(old_inode->i_mode))
|
||||
|
||||
@@ -6994,6 +6994,9 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
||||
u64 root_objectid;
|
||||
int ret;
|
||||
|
||||
if (new_inode && S_ISDIR(new_dentry->d_inode->i_mode))
|
||||
dentry_unhash(new_dentry);
|
||||
|
||||
if (new_dir->i_ino == BTRFS_EMPTY_SUBVOL_DIR_OBJECTID)
|
||||
return -EPERM;
|
||||
|
||||
|
||||
@@ -869,6 +869,9 @@ static int ceph_rename(struct inode *old_dir, struct dentry *old_dentry,
|
||||
struct ceph_mds_request *req;
|
||||
int err;
|
||||
|
||||
if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode))
|
||||
dentry_unhash(new_dentry);
|
||||
|
||||
if (ceph_snap(old_dir) != ceph_snap(new_dir))
|
||||
return -EXDEV;
|
||||
if (ceph_snap(old_dir) != CEPH_NOSNAP ||
|
||||
|
||||
@@ -1571,6 +1571,9 @@ int cifs_rename(struct inode *source_dir, struct dentry *source_dentry,
|
||||
FILE_UNIX_BASIC_INFO *info_buf_target;
|
||||
int xid, rc, tmprc;
|
||||
|
||||
if (target_dentry->d_inode && S_ISDIR(target_dentry->d_inode->i_mode))
|
||||
dentry_unhash(target_dentry);
|
||||
|
||||
cifs_sb = CIFS_SB(source_dir->i_sb);
|
||||
tlink = cifs_sb_tlink(cifs_sb);
|
||||
if (IS_ERR(tlink))
|
||||
|
||||
@@ -361,6 +361,9 @@ static int coda_rename(struct inode *old_dir, struct dentry *old_dentry,
|
||||
int new_length = new_dentry->d_name.len;
|
||||
int error;
|
||||
|
||||
if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode))
|
||||
dentry_unhash(new_dentry);
|
||||
|
||||
error = venus_rename(old_dir->i_sb, coda_i2f(old_dir),
|
||||
coda_i2f(new_dir), old_length, new_length,
|
||||
(const char *) old_name, (const char *)new_name);
|
||||
|
||||
@@ -573,6 +573,9 @@ ecryptfs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
||||
struct dentry *lower_new_dir_dentry;
|
||||
struct dentry *trap = NULL;
|
||||
|
||||
if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode))
|
||||
dentry_unhash(new_dentry);
|
||||
|
||||
lower_old_dentry = ecryptfs_dentry_to_lower(old_dentry);
|
||||
lower_new_dentry = ecryptfs_dentry_to_lower(new_dentry);
|
||||
dget(lower_old_dentry);
|
||||
|
||||
@@ -251,6 +251,9 @@ static int exofs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
||||
struct exofs_dir_entry *old_de;
|
||||
int err = -ENOENT;
|
||||
|
||||
if (new_inode && S_ISDIR(new_inode->i_mode))
|
||||
dentry_unhash(new_dentry);
|
||||
|
||||
old_de = exofs_find_entry(old_dir, old_dentry, &old_page);
|
||||
if (!old_de)
|
||||
goto out;
|
||||
|
||||
@@ -320,6 +320,9 @@ static int ext2_rename (struct inode * old_dir, struct dentry * old_dentry,
|
||||
struct ext2_dir_entry_2 * old_de;
|
||||
int err = -ENOENT;
|
||||
|
||||
if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode))
|
||||
dentry_unhash(new_dentry);
|
||||
|
||||
dquot_initialize(old_dir);
|
||||
dquot_initialize(new_dir);
|
||||
|
||||
|
||||
@@ -2298,6 +2298,9 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry,
|
||||
struct ext3_dir_entry_2 * old_de, * new_de;
|
||||
int retval, flush_file = 0;
|
||||
|
||||
if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode))
|
||||
dentry_unhash(new_dentry);
|
||||
|
||||
dquot_initialize(old_dir);
|
||||
dquot_initialize(new_dir);
|
||||
|
||||
|
||||
@@ -2352,6 +2352,9 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
|
||||
struct ext4_dir_entry_2 *old_de, *new_de;
|
||||
int retval, force_da_alloc = 0;
|
||||
|
||||
if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode))
|
||||
dentry_unhash(new_dentry);
|
||||
|
||||
dquot_initialize(old_dir);
|
||||
dquot_initialize(new_dir);
|
||||
|
||||
|
||||
@@ -459,6 +459,9 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name,
|
||||
old_inode = old_dentry->d_inode;
|
||||
new_inode = new_dentry->d_inode;
|
||||
|
||||
if (new_inode && S_ISDIR(new_inode->i_mode))
|
||||
dentry_unhash(new_dentry);
|
||||
|
||||
err = fat_scan(old_dir, old_name, &old_sinfo);
|
||||
if (err) {
|
||||
err = -EIO;
|
||||
|
||||
@@ -933,6 +933,9 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry,
|
||||
int err, is_dir, update_dotdot, corrupt = 0;
|
||||
struct super_block *sb = old_dir->i_sb;
|
||||
|
||||
if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode))
|
||||
dentry_unhash(new_dentry);
|
||||
|
||||
old_sinfo.bh = sinfo.bh = dotdot_bh = NULL;
|
||||
old_inode = old_dentry->d_inode;
|
||||
new_inode = new_dentry->d_inode;
|
||||
|
||||
@@ -693,6 +693,10 @@ static int fuse_rename(struct inode *olddir, struct dentry *oldent,
|
||||
struct fuse_rename_in inarg;
|
||||
struct fuse_conn *fc = get_fuse_conn(olddir);
|
||||
struct fuse_req *req = fuse_get_req(fc);
|
||||
|
||||
if (newent->d_inode && S_ISDIR(newent->d_inode->i_mode))
|
||||
dentry_unhash(newent);
|
||||
|
||||
if (IS_ERR(req))
|
||||
return PTR_ERR(req);
|
||||
|
||||
|
||||
@@ -286,6 +286,9 @@ static int hfs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
||||
|
||||
/* Unlink destination if it already exists */
|
||||
if (new_dentry->d_inode) {
|
||||
if (S_ISDIR(new_dentry->d_inode->i_mode))
|
||||
dentry_unhash(new_dentry);
|
||||
|
||||
res = hfs_remove(new_dir, new_dentry);
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
+4
-2
@@ -469,10 +469,12 @@ static int hfsplus_rename(struct inode *old_dir, struct dentry *old_dentry,
|
||||
|
||||
/* Unlink destination if it already exists */
|
||||
if (new_dentry->d_inode) {
|
||||
if (S_ISDIR(new_dentry->d_inode->i_mode))
|
||||
if (S_ISDIR(new_dentry->d_inode->i_mode)) {
|
||||
dentry_unhash(new_dentry);
|
||||
res = hfsplus_rmdir(new_dir, new_dentry);
|
||||
else
|
||||
} else {
|
||||
res = hfsplus_unlink(new_dir, new_dentry);
|
||||
}
|
||||
if (res)
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -738,6 +738,9 @@ int hostfs_rename(struct inode *from_ino, struct dentry *from,
|
||||
char *from_name, *to_name;
|
||||
int err;
|
||||
|
||||
if (to->d_inode && S_ISDIR(to->d_inode->i_mode))
|
||||
dentry_unhash(to);
|
||||
|
||||
if ((from_name = dentry_name(from)) == NULL)
|
||||
return -ENOMEM;
|
||||
if ((to_name = dentry_name(to)) == NULL) {
|
||||
|
||||
@@ -561,6 +561,10 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
||||
struct buffer_head *bh;
|
||||
struct fnode *fnode;
|
||||
int err;
|
||||
|
||||
if (new_inode && S_ISDIR(new_inode->i_mode))
|
||||
dentry_unhash(new_dentry);
|
||||
|
||||
if ((err = hpfs_chk_name(new_name, &new_len))) return err;
|
||||
err = 0;
|
||||
hpfs_adjust_length(old_name, &old_len);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user