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
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6: (25 commits) cifs: remove unnecessary dentry_unhash on rmdir/rename_dir ocfs2: remove unnecessary dentry_unhash on rmdir/rename_dir exofs: remove unnecessary dentry_unhash on rmdir/rename_dir nfs: remove unnecessary dentry_unhash on rmdir/rename_dir ext2: remove unnecessary dentry_unhash on rmdir/rename_dir ext3: remove unnecessary dentry_unhash on rmdir/rename_dir ext4: remove unnecessary dentry_unhash on rmdir/rename_dir btrfs: remove unnecessary dentry_unhash in rmdir/rename_dir ceph: remove unnecessary dentry_unhash calls vfs: clean up vfs_rename_other vfs: clean up vfs_rename_dir vfs: clean up vfs_rmdir vfs: fix vfs_rename_dir for FS_RENAME_DOES_D_MOVE filesystems libfs: drop unneeded dentry_unhash vfs: update dentry_unhash() comment vfs: push dentry_unhash on rename_dir into file systems vfs: push dentry_unhash on rmdir into file systems vfs: remove dget() from dentry_unhash() vfs: dentry_unhash immediately prior to rmdir vfs: Block mmapped writes while the fs is frozen ...
This commit is contained in:
@@ -814,6 +814,7 @@ int v9fs_vfs_unlink(struct inode *i, struct dentry *d)
|
||||
|
||||
int v9fs_vfs_rmdir(struct inode *i, struct dentry *d)
|
||||
{
|
||||
dentry_unhash(d);
|
||||
return v9fs_remove(i, d, 1);
|
||||
}
|
||||
|
||||
@@ -839,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;
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ config FS_POSIX_ACL
|
||||
def_bool n
|
||||
|
||||
config EXPORTFS
|
||||
bool
|
||||
tristate
|
||||
|
||||
config FILE_LOCKING
|
||||
bool "Enable POSIX file locking API" if EXPERT
|
||||
|
||||
@@ -320,6 +320,8 @@ affs_rmdir(struct inode *dir, struct dentry *dentry)
|
||||
dentry->d_inode->i_ino,
|
||||
(int)dentry->d_name.len, dentry->d_name.name);
|
||||
|
||||
dentry_unhash(dentry);
|
||||
|
||||
return affs_remove_header(dentry);
|
||||
}
|
||||
|
||||
@@ -417,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);
|
||||
|
||||
@@ -845,6 +845,8 @@ static int afs_rmdir(struct inode *dir, struct dentry *dentry)
|
||||
_enter("{%x:%u},{%s}",
|
||||
dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name);
|
||||
|
||||
dentry_unhash(dentry);
|
||||
|
||||
ret = -ENAMETOOLONG;
|
||||
if (dentry->d_name.len >= AFSNAMEMAX)
|
||||
goto error;
|
||||
@@ -1146,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);
|
||||
|
||||
@@ -583,6 +583,8 @@ static int autofs4_dir_unlink(struct inode *dir, struct dentry *dentry)
|
||||
if (!autofs4_oz_mode(sbi) && !capable(CAP_SYS_ADMIN))
|
||||
return -EACCES;
|
||||
|
||||
dentry_unhash(dentry);
|
||||
|
||||
if (atomic_dec_and_test(&ino->count)) {
|
||||
p_ino = autofs4_dentry_ino(dentry->d_parent);
|
||||
if (p_ino && dentry->d_parent != dentry)
|
||||
|
||||
@@ -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))
|
||||
|
||||
+40
-15
@@ -2331,24 +2331,26 @@ EXPORT_SYMBOL(block_commit_write);
|
||||
* page lock we can determine safely if the page is beyond EOF. If it is not
|
||||
* beyond EOF, then the page is guaranteed safe against truncation until we
|
||||
* unlock the page.
|
||||
*
|
||||
* Direct callers of this function should call vfs_check_frozen() so that page
|
||||
* fault does not busyloop until the fs is thawed.
|
||||
*/
|
||||
int
|
||||
block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,
|
||||
int __block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,
|
||||
get_block_t get_block)
|
||||
{
|
||||
struct page *page = vmf->page;
|
||||
struct inode *inode = vma->vm_file->f_path.dentry->d_inode;
|
||||
unsigned long end;
|
||||
loff_t size;
|
||||
int ret = VM_FAULT_NOPAGE; /* make the VM retry the fault */
|
||||
int ret;
|
||||
|
||||
lock_page(page);
|
||||
size = i_size_read(inode);
|
||||
if ((page->mapping != inode->i_mapping) ||
|
||||
(page_offset(page) > size)) {
|
||||
/* page got truncated out from underneath us */
|
||||
unlock_page(page);
|
||||
goto out;
|
||||
/* We overload EFAULT to mean page got truncated */
|
||||
ret = -EFAULT;
|
||||
goto out_unlock;
|
||||
}
|
||||
|
||||
/* page is wholly or partially inside EOF */
|
||||
@@ -2361,18 +2363,41 @@ block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,
|
||||
if (!ret)
|
||||
ret = block_commit_write(page, 0, end);
|
||||
|
||||
if (unlikely(ret)) {
|
||||
if (unlikely(ret < 0))
|
||||
goto out_unlock;
|
||||
/*
|
||||
* Freezing in progress? We check after the page is marked dirty and
|
||||
* with page lock held so if the test here fails, we are sure freezing
|
||||
* code will wait during syncing until the page fault is done - at that
|
||||
* point page will be dirty and unlocked so freezing code will write it
|
||||
* and writeprotect it again.
|
||||
*/
|
||||
set_page_dirty(page);
|
||||
if (inode->i_sb->s_frozen != SB_UNFROZEN) {
|
||||
ret = -EAGAIN;
|
||||
goto out_unlock;
|
||||
}
|
||||
return 0;
|
||||
out_unlock:
|
||||
unlock_page(page);
|
||||
if (ret == -ENOMEM)
|
||||
ret = VM_FAULT_OOM;
|
||||
else /* -ENOSPC, -EIO, etc */
|
||||
ret = VM_FAULT_SIGBUS;
|
||||
} else
|
||||
ret = VM_FAULT_LOCKED;
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(__block_page_mkwrite);
|
||||
|
||||
int block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,
|
||||
get_block_t get_block)
|
||||
{
|
||||
int ret;
|
||||
struct super_block *sb = vma->vm_file->f_path.dentry->d_inode->i_sb;
|
||||
|
||||
/*
|
||||
* This check is racy but catches the common case. The check in
|
||||
* __block_page_mkwrite() is reliable.
|
||||
*/
|
||||
vfs_check_frozen(sb, SB_FREEZE_WRITE);
|
||||
ret = __block_page_mkwrite(vma, vmf, get_block);
|
||||
return block_page_mkwrite_return(ret);
|
||||
}
|
||||
EXPORT_SYMBOL(block_page_mkwrite);
|
||||
|
||||
/*
|
||||
|
||||
@@ -336,6 +336,8 @@ static int coda_rmdir(struct inode *dir, struct dentry *de)
|
||||
int len = de->d_name.len;
|
||||
int error;
|
||||
|
||||
dentry_unhash(de);
|
||||
|
||||
error = venus_rmdir(dir->i_sb, coda_i2f(dir), name, len);
|
||||
if (!error) {
|
||||
/* VFS may delete the child */
|
||||
@@ -359,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);
|
||||
|
||||
@@ -1359,6 +1359,8 @@ static int configfs_rmdir(struct inode *dir, struct dentry *dentry)
|
||||
struct module *subsys_owner = NULL, *dead_item_owner = NULL;
|
||||
int ret;
|
||||
|
||||
dentry_unhash(dentry);
|
||||
|
||||
if (dentry->d_parent == configfs_sb->s_root)
|
||||
return -EPERM;
|
||||
|
||||
|
||||
@@ -521,6 +521,8 @@ static int ecryptfs_rmdir(struct inode *dir, struct dentry *dentry)
|
||||
struct dentry *lower_dir_dentry;
|
||||
int rc;
|
||||
|
||||
dentry_unhash(dentry);
|
||||
|
||||
lower_dentry = ecryptfs_dentry_to_lower(dentry);
|
||||
dget(dentry);
|
||||
lower_dir_dentry = lock_parent(lower_dentry);
|
||||
@@ -571,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);
|
||||
|
||||
@@ -326,6 +326,8 @@ static int msdos_rmdir(struct inode *dir, struct dentry *dentry)
|
||||
struct fat_slot_info sinfo;
|
||||
int err;
|
||||
|
||||
dentry_unhash(dentry);
|
||||
|
||||
lock_super(sb);
|
||||
/*
|
||||
* Check whether the directory is not in use, then check
|
||||
@@ -457,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;
|
||||
|
||||
@@ -824,6 +824,8 @@ static int vfat_rmdir(struct inode *dir, struct dentry *dentry)
|
||||
struct fat_slot_info sinfo;
|
||||
int err;
|
||||
|
||||
dentry_unhash(dentry);
|
||||
|
||||
lock_super(sb);
|
||||
|
||||
err = fat_dir_empty(inode);
|
||||
@@ -931,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;
|
||||
|
||||
@@ -667,6 +667,8 @@ static int fuse_rmdir(struct inode *dir, struct dentry *entry)
|
||||
if (IS_ERR(req))
|
||||
return PTR_ERR(req);
|
||||
|
||||
dentry_unhash(entry);
|
||||
|
||||
req->in.h.opcode = FUSE_RMDIR;
|
||||
req->in.h.nodeid = get_node_id(dir);
|
||||
req->in.numargs = 1;
|
||||
@@ -691,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);
|
||||
|
||||
|
||||
@@ -253,6 +253,9 @@ static int hfs_remove(struct inode *dir, struct dentry *dentry)
|
||||
struct inode *inode = dentry->d_inode;
|
||||
int res;
|
||||
|
||||
if (S_ISDIR(inode->i_mode))
|
||||
dentry_unhash(dentry);
|
||||
|
||||
if (S_ISDIR(inode->i_mode) && inode->i_size != 2)
|
||||
return -ENOTEMPTY;
|
||||
res = hfs_cat_delete(inode->i_ino, dir, &dentry->d_name);
|
||||
@@ -283,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;
|
||||
|
||||
+6
-2
@@ -370,6 +370,8 @@ static int hfsplus_rmdir(struct inode *dir, struct dentry *dentry)
|
||||
struct inode *inode = dentry->d_inode;
|
||||
int res;
|
||||
|
||||
dentry_unhash(dentry);
|
||||
|
||||
if (inode->i_size != 2)
|
||||
return -ENOTEMPTY;
|
||||
|
||||
@@ -467,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;
|
||||
}
|
||||
|
||||
@@ -683,6 +683,8 @@ int hostfs_rmdir(struct inode *ino, struct dentry *dentry)
|
||||
char *file;
|
||||
int err;
|
||||
|
||||
dentry_unhash(dentry);
|
||||
|
||||
if ((file = dentry_name(dentry)) == NULL)
|
||||
return -ENOMEM;
|
||||
err = do_rmdir(file);
|
||||
@@ -736,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) {
|
||||
|
||||
+6
-3
@@ -395,7 +395,6 @@ again:
|
||||
|
||||
dentry_unhash(dentry);
|
||||
if (!d_unhashed(dentry)) {
|
||||
dput(dentry);
|
||||
hpfs_unlock(dir->i_sb);
|
||||
return -ENOSPC;
|
||||
}
|
||||
@@ -403,7 +402,6 @@ again:
|
||||
!S_ISREG(inode->i_mode) ||
|
||||
get_write_access(inode)) {
|
||||
d_rehash(dentry);
|
||||
dput(dentry);
|
||||
} else {
|
||||
struct iattr newattrs;
|
||||
/*printk("HPFS: truncating file before delete.\n");*/
|
||||
@@ -411,7 +409,6 @@ again:
|
||||
newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
|
||||
err = notify_change(dentry, &newattrs);
|
||||
put_write_access(inode);
|
||||
dput(dentry);
|
||||
if (!err)
|
||||
goto again;
|
||||
}
|
||||
@@ -442,6 +439,8 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry)
|
||||
int err;
|
||||
int r;
|
||||
|
||||
dentry_unhash(dentry);
|
||||
|
||||
hpfs_adjust_length(name, &len);
|
||||
hpfs_lock(dir->i_sb);
|
||||
err = -ENOENT;
|
||||
@@ -535,6 +534,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);
|
||||
|
||||
@@ -609,6 +609,8 @@ static int jffs2_rmdir (struct inode *dir_i, struct dentry *dentry)
|
||||
int ret;
|
||||
uint32_t now = get_seconds();
|
||||
|
||||
dentry_unhash(dentry);
|
||||
|
||||
for (fd = f->dents ; fd; fd = fd->next) {
|
||||
if (fd->ino)
|
||||
return -ENOTEMPTY;
|
||||
@@ -784,6 +786,9 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
|
||||
uint8_t type;
|
||||
uint32_t now;
|
||||
|
||||
if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode))
|
||||
dentry_unhash(new_dentry);
|
||||
|
||||
/* The VFS will check for us and prevent trying to rename a
|
||||
* file over a directory and vice versa, but if it's a directory,
|
||||
* the VFS can't check whether the victim is empty. The filesystem
|
||||
|
||||
@@ -360,6 +360,8 @@ static int jfs_rmdir(struct inode *dip, struct dentry *dentry)
|
||||
|
||||
jfs_info("jfs_rmdir: dip:0x%p name:%s", dip, dentry->d_name.name);
|
||||
|
||||
dentry_unhash(dentry);
|
||||
|
||||
/* Init inode for quota operations. */
|
||||
dquot_initialize(dip);
|
||||
dquot_initialize(ip);
|
||||
@@ -1095,6 +1097,9 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
||||
jfs_info("jfs_rename: %s %s", old_dentry->d_name.name,
|
||||
new_dentry->d_name.name);
|
||||
|
||||
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);
|
||||
|
||||
|
||||
@@ -273,6 +273,8 @@ static int logfs_rmdir(struct inode *dir, struct dentry *dentry)
|
||||
{
|
||||
struct inode *inode = dentry->d_inode;
|
||||
|
||||
dentry_unhash(dentry);
|
||||
|
||||
if (!logfs_empty_dir(inode))
|
||||
return -ENOTEMPTY;
|
||||
|
||||
@@ -622,6 +624,9 @@ static int logfs_rename_cross(struct inode *old_dir, struct dentry *old_dentry,
|
||||
loff_t pos;
|
||||
int err;
|
||||
|
||||
if (new_dentry->d_inode && S_ISDIR(new_dentry->d_inode->i_mode))
|
||||
dentry_unhash(new_dentry);
|
||||
|
||||
/* 1. locate source dd */
|
||||
err = logfs_get_dd(old_dir, old_dentry, &dd, &pos);
|
||||
if (err)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user