fs: make remaining filesystems use .rename2
This is trivial to do: - add flags argument to foo_rename() - check if flags is zero - assign foo_rename() to .rename2 instead of .rename This doesn't mean it's impossible to support RENAME_NOREPLACE for these filesystems, but it is not trivial, like for local filesystems. RENAME_NOREPLACE must guarantee atomicity (i.e. it shouldn't be possible for a file to be created on one host while it is overwritten by rename on another host). Filesystems converted: 9p, afs, ceph, coda, ecryptfs, kernfs, lustre, ncpfs, nfs, ocfs2, orangefs. After this, we can get rid of the duplicate interfaces for rename. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: David Howells <dhowells@redhat.com> [AFS] Acked-by: Mike Marshall <hubcap@omnibond.com> Cc: Eric Van Hensbergen <ericvh@gmail.com> Cc: Ilya Dryomov <idryomov@gmail.com> Cc: Jan Harkes <jaharkes@cs.cmu.edu> Cc: Tyler Hicks <tyhicks@canonical.com> Cc: Oleg Drokin <oleg.drokin@intel.com> Cc: Trond Myklebust <trond.myklebust@primarydata.com> Cc: Mark Fasheh <mfasheh@suse.com>
This commit is contained in:
Родитель
e0e0be8a83
Коммит
1cd66c93ba
|
@ -1050,13 +1050,17 @@ out:
|
|||
}
|
||||
|
||||
static int ll_rename(struct inode *src, struct dentry *src_dchild,
|
||||
struct inode *tgt, struct dentry *tgt_dchild)
|
||||
struct inode *tgt, struct dentry *tgt_dchild,
|
||||
unsigned int flags)
|
||||
{
|
||||
struct ptlrpc_request *request = NULL;
|
||||
struct ll_sb_info *sbi = ll_i2sbi(src);
|
||||
struct md_op_data *op_data;
|
||||
int err;
|
||||
|
||||
if (flags)
|
||||
return -EINVAL;
|
||||
|
||||
CDEBUG(D_VFSTRACE,
|
||||
"VFS Op:oldname=%pd, src_dir="DFID"(%p), newname=%pd, tgt_dir="DFID"(%p)\n",
|
||||
src_dchild, PFID(ll_inode2fid(src)), src,
|
||||
|
@ -1102,7 +1106,7 @@ const struct inode_operations ll_dir_inode_operations = {
|
|||
.rmdir = ll_rmdir,
|
||||
.symlink = ll_symlink,
|
||||
.link = ll_link,
|
||||
.rename = ll_rename,
|
||||
.rename2 = ll_rename,
|
||||
.setattr = ll_setattr,
|
||||
.getattr = ll_getattr,
|
||||
.permission = ll_inode_permission,
|
||||
|
|
|
@ -148,7 +148,8 @@ extern struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
|
|||
extern int v9fs_vfs_unlink(struct inode *i, struct dentry *d);
|
||||
extern int v9fs_vfs_rmdir(struct inode *i, struct dentry *d);
|
||||
extern int v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
||||
struct inode *new_dir, struct dentry *new_dentry);
|
||||
struct inode *new_dir, struct dentry *new_dentry,
|
||||
unsigned int flags);
|
||||
extern struct inode *v9fs_inode_from_fid(struct v9fs_session_info *v9ses,
|
||||
struct p9_fid *fid,
|
||||
struct super_block *sb, int new);
|
||||
|
|
|
@ -955,7 +955,8 @@ int v9fs_vfs_rmdir(struct inode *i, struct dentry *d)
|
|||
|
||||
int
|
||||
v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
||||
struct inode *new_dir, struct dentry *new_dentry)
|
||||
struct inode *new_dir, struct dentry *new_dentry,
|
||||
unsigned int flags)
|
||||
{
|
||||
int retval;
|
||||
struct inode *old_inode;
|
||||
|
@ -966,6 +967,9 @@ v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
|||
struct p9_fid *newdirfid;
|
||||
struct p9_wstat wstat;
|
||||
|
||||
if (flags)
|
||||
return -EINVAL;
|
||||
|
||||
p9_debug(P9_DEBUG_VFS, "\n");
|
||||
retval = 0;
|
||||
old_inode = d_inode(old_dentry);
|
||||
|
@ -1436,7 +1440,7 @@ static const struct inode_operations v9fs_dir_inode_operations_dotu = {
|
|||
.mkdir = v9fs_vfs_mkdir,
|
||||
.rmdir = v9fs_vfs_rmdir,
|
||||
.mknod = v9fs_vfs_mknod,
|
||||
.rename = v9fs_vfs_rename,
|
||||
.rename2 = v9fs_vfs_rename,
|
||||
.getattr = v9fs_vfs_getattr,
|
||||
.setattr = v9fs_vfs_setattr,
|
||||
};
|
||||
|
@ -1449,7 +1453,7 @@ static const struct inode_operations v9fs_dir_inode_operations = {
|
|||
.mkdir = v9fs_vfs_mkdir,
|
||||
.rmdir = v9fs_vfs_rmdir,
|
||||
.mknod = v9fs_vfs_mknod,
|
||||
.rename = v9fs_vfs_rename,
|
||||
.rename2 = v9fs_vfs_rename,
|
||||
.getattr = v9fs_vfs_getattr,
|
||||
.setattr = v9fs_vfs_setattr,
|
||||
};
|
||||
|
|
|
@ -964,7 +964,7 @@ const struct inode_operations v9fs_dir_inode_operations_dotl = {
|
|||
.mkdir = v9fs_vfs_mkdir_dotl,
|
||||
.rmdir = v9fs_vfs_rmdir,
|
||||
.mknod = v9fs_vfs_mknod_dotl,
|
||||
.rename = v9fs_vfs_rename,
|
||||
.rename2 = v9fs_vfs_rename,
|
||||
.getattr = v9fs_vfs_getattr_dotl,
|
||||
.setattr = v9fs_vfs_setattr_dotl,
|
||||
.setxattr = generic_setxattr,
|
||||
|
|
11
fs/afs/dir.c
11
fs/afs/dir.c
|
@ -38,7 +38,8 @@ static int afs_link(struct dentry *from, struct inode *dir,
|
|||
static int afs_symlink(struct inode *dir, struct dentry *dentry,
|
||||
const char *content);
|
||||
static int afs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
||||
struct inode *new_dir, struct dentry *new_dentry);
|
||||
struct inode *new_dir, struct dentry *new_dentry,
|
||||
unsigned int flags);
|
||||
|
||||
const struct file_operations afs_dir_file_operations = {
|
||||
.open = afs_dir_open,
|
||||
|
@ -56,7 +57,7 @@ const struct inode_operations afs_dir_inode_operations = {
|
|||
.symlink = afs_symlink,
|
||||
.mkdir = afs_mkdir,
|
||||
.rmdir = afs_rmdir,
|
||||
.rename = afs_rename,
|
||||
.rename2 = afs_rename,
|
||||
.permission = afs_permission,
|
||||
.getattr = afs_getattr,
|
||||
.setattr = afs_setattr,
|
||||
|
@ -1083,12 +1084,16 @@ error:
|
|||
* rename a file in an AFS filesystem and/or move it between directories
|
||||
*/
|
||||
static int afs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
||||
struct inode *new_dir, struct dentry *new_dentry)
|
||||
struct inode *new_dir, struct dentry *new_dentry,
|
||||
unsigned int flags)
|
||||
{
|
||||
struct afs_vnode *orig_dvnode, *new_dvnode, *vnode;
|
||||
struct key *key;
|
||||
int ret;
|
||||
|
||||
if (flags)
|
||||
return -EINVAL;
|
||||
|
||||
vnode = AFS_FS_I(d_inode(old_dentry));
|
||||
orig_dvnode = AFS_FS_I(old_dir);
|
||||
new_dvnode = AFS_FS_I(new_dir);
|
||||
|
|
|
@ -1061,7 +1061,8 @@ out:
|
|||
}
|
||||
|
||||
static int ceph_rename(struct inode *old_dir, struct dentry *old_dentry,
|
||||
struct inode *new_dir, struct dentry *new_dentry)
|
||||
struct inode *new_dir, struct dentry *new_dentry,
|
||||
unsigned int flags)
|
||||
{
|
||||
struct ceph_fs_client *fsc = ceph_sb_to_client(old_dir->i_sb);
|
||||
struct ceph_mds_client *mdsc = fsc->mdsc;
|
||||
|
@ -1069,6 +1070,9 @@ static int ceph_rename(struct inode *old_dir, struct dentry *old_dentry,
|
|||
int op = CEPH_MDS_OP_RENAME;
|
||||
int err;
|
||||
|
||||
if (flags)
|
||||
return -EINVAL;
|
||||
|
||||
if (ceph_snap(old_dir) != ceph_snap(new_dir))
|
||||
return -EXDEV;
|
||||
if (ceph_snap(old_dir) != CEPH_NOSNAP) {
|
||||
|
@ -1498,7 +1502,7 @@ const struct inode_operations ceph_dir_iops = {
|
|||
.link = ceph_link,
|
||||
.unlink = ceph_unlink,
|
||||
.rmdir = ceph_unlink,
|
||||
.rename = ceph_rename,
|
||||
.rename2 = ceph_rename,
|
||||
.create = ceph_create,
|
||||
.atomic_open = ceph_atomic_open,
|
||||
};
|
||||
|
@ -1509,7 +1513,7 @@ const struct inode_operations ceph_snapdir_iops = {
|
|||
.getattr = ceph_getattr,
|
||||
.mkdir = ceph_mkdir,
|
||||
.rmdir = ceph_unlink,
|
||||
.rename = ceph_rename,
|
||||
.rename2 = ceph_rename,
|
||||
};
|
||||
|
||||
const struct dentry_operations ceph_dentry_ops = {
|
||||
|
|
|
@ -291,7 +291,8 @@ static int coda_rmdir(struct inode *dir, struct dentry *de)
|
|||
|
||||
/* rename */
|
||||
static int coda_rename(struct inode *old_dir, struct dentry *old_dentry,
|
||||
struct inode *new_dir, struct dentry *new_dentry)
|
||||
struct inode *new_dir, struct dentry *new_dentry,
|
||||
unsigned int flags)
|
||||
{
|
||||
const char *old_name = old_dentry->d_name.name;
|
||||
const char *new_name = new_dentry->d_name.name;
|
||||
|
@ -299,6 +300,9 @@ static int coda_rename(struct inode *old_dir, struct dentry *old_dentry,
|
|||
int new_length = new_dentry->d_name.len;
|
||||
int error;
|
||||
|
||||
if (flags)
|
||||
return -EINVAL;
|
||||
|
||||
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);
|
||||
|
@ -569,7 +573,7 @@ const struct inode_operations coda_dir_inode_operations = {
|
|||
.mkdir = coda_mkdir,
|
||||
.rmdir = coda_rmdir,
|
||||
.mknod = CODA_EIO_ERROR,
|
||||
.rename = coda_rename,
|
||||
.rename2 = coda_rename,
|
||||
.permission = coda_permission,
|
||||
.getattr = coda_getattr,
|
||||
.setattr = coda_setattr,
|
||||
|
|
|
@ -577,7 +577,8 @@ out:
|
|||
|
||||
static int
|
||||
ecryptfs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
||||
struct inode *new_dir, struct dentry *new_dentry)
|
||||
struct inode *new_dir, struct dentry *new_dentry,
|
||||
unsigned int flags)
|
||||
{
|
||||
int rc;
|
||||
struct dentry *lower_old_dentry;
|
||||
|
@ -587,6 +588,9 @@ ecryptfs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
|||
struct dentry *trap = NULL;
|
||||
struct inode *target_inode;
|
||||
|
||||
if (flags)
|
||||
return -EINVAL;
|
||||
|
||||
lower_old_dentry = ecryptfs_dentry_to_lower(old_dentry);
|
||||
lower_new_dentry = ecryptfs_dentry_to_lower(new_dentry);
|
||||
dget(lower_old_dentry);
|
||||
|
@ -1104,7 +1108,7 @@ const struct inode_operations ecryptfs_dir_iops = {
|
|||
.mkdir = ecryptfs_mkdir,
|
||||
.rmdir = ecryptfs_rmdir,
|
||||
.mknod = ecryptfs_mknod,
|
||||
.rename = ecryptfs_rename,
|
||||
.rename2 = ecryptfs_rename,
|
||||
.permission = ecryptfs_permission,
|
||||
.setattr = ecryptfs_setattr,
|
||||
.setxattr = ecryptfs_setxattr,
|
||||
|
|
|
@ -1096,13 +1096,17 @@ static int kernfs_iop_rmdir(struct inode *dir, struct dentry *dentry)
|
|||
}
|
||||
|
||||
static int kernfs_iop_rename(struct inode *old_dir, struct dentry *old_dentry,
|
||||
struct inode *new_dir, struct dentry *new_dentry)
|
||||
struct inode *new_dir, struct dentry *new_dentry,
|
||||
unsigned int flags)
|
||||
{
|
||||
struct kernfs_node *kn = old_dentry->d_fsdata;
|
||||
struct kernfs_node *new_parent = new_dir->i_private;
|
||||
struct kernfs_syscall_ops *scops = kernfs_root(kn)->syscall_ops;
|
||||
int ret;
|
||||
|
||||
if (flags)
|
||||
return -EINVAL;
|
||||
|
||||
if (!scops || !scops->rename)
|
||||
return -EPERM;
|
||||
|
||||
|
@ -1133,7 +1137,7 @@ const struct inode_operations kernfs_dir_iops = {
|
|||
|
||||
.mkdir = kernfs_iop_mkdir,
|
||||
.rmdir = kernfs_iop_rmdir,
|
||||
.rename = kernfs_iop_rename,
|
||||
.rename2 = kernfs_iop_rename,
|
||||
};
|
||||
|
||||
static struct kernfs_node *kernfs_leftmost_descendant(struct kernfs_node *pos)
|
||||
|
|
|
@ -36,7 +36,7 @@ static int ncp_unlink(struct inode *, struct dentry *);
|
|||
static int ncp_mkdir(struct inode *, struct dentry *, umode_t);
|
||||
static int ncp_rmdir(struct inode *, struct dentry *);
|
||||
static int ncp_rename(struct inode *, struct dentry *,
|
||||
struct inode *, struct dentry *);
|
||||
struct inode *, struct dentry *, unsigned int);
|
||||
static int ncp_mknod(struct inode * dir, struct dentry *dentry,
|
||||
umode_t mode, dev_t rdev);
|
||||
#if defined(CONFIG_NCPFS_EXTRAS) || defined(CONFIG_NCPFS_NFS_NS)
|
||||
|
@ -65,7 +65,7 @@ const struct inode_operations ncp_dir_inode_operations =
|
|||
.mkdir = ncp_mkdir,
|
||||
.rmdir = ncp_rmdir,
|
||||
.mknod = ncp_mknod,
|
||||
.rename = ncp_rename,
|
||||
.rename2 = ncp_rename,
|
||||
.setattr = ncp_notify_change,
|
||||
};
|
||||
|
||||
|
@ -1105,13 +1105,17 @@ static int ncp_unlink(struct inode *dir, struct dentry *dentry)
|
|||
}
|
||||
|
||||
static int ncp_rename(struct inode *old_dir, struct dentry *old_dentry,
|
||||
struct inode *new_dir, struct dentry *new_dentry)
|
||||
struct inode *new_dir, struct dentry *new_dentry,
|
||||
unsigned int flags)
|
||||
{
|
||||
struct ncp_server *server = NCP_SERVER(old_dir);
|
||||
int error;
|
||||
int old_len, new_len;
|
||||
__u8 __old_name[NCP_MAXPATHLEN + 1], __new_name[NCP_MAXPATHLEN + 1];
|
||||
|
||||
if (flags)
|
||||
return -EINVAL;
|
||||
|
||||
ncp_dbg(1, "%pd2 to %pd2\n", old_dentry, new_dentry);
|
||||
|
||||
ncp_age_dentry(server, old_dentry);
|
||||
|
|
|
@ -2013,7 +2013,8 @@ EXPORT_SYMBOL_GPL(nfs_link);
|
|||
* the rename.
|
||||
*/
|
||||
int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
||||
struct inode *new_dir, struct dentry *new_dentry)
|
||||
struct inode *new_dir, struct dentry *new_dentry,
|
||||
unsigned int flags)
|
||||
{
|
||||
struct inode *old_inode = d_inode(old_dentry);
|
||||
struct inode *new_inode = d_inode(new_dentry);
|
||||
|
@ -2021,6 +2022,9 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
|||
struct rpc_task *task;
|
||||
int error = -EBUSY;
|
||||
|
||||
if (flags)
|
||||
return -EINVAL;
|
||||
|
||||
dfprintk(VFS, "NFS: rename(%pd2 -> %pd2, ct=%d)\n",
|
||||
old_dentry, new_dentry,
|
||||
d_count(new_dentry));
|
||||
|
|
|
@ -359,7 +359,8 @@ int nfs_unlink(struct inode *, struct dentry *);
|
|||
int nfs_symlink(struct inode *, struct dentry *, const char *);
|
||||
int nfs_link(struct dentry *, struct inode *, struct dentry *);
|
||||
int nfs_mknod(struct inode *, struct dentry *, umode_t, dev_t);
|
||||
int nfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
|
||||
int nfs_rename(struct inode *, struct dentry *,
|
||||
struct inode *, struct dentry *, unsigned int);
|
||||
|
||||
/* file.c */
|
||||
int nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync);
|
||||
|
|
|
@ -893,7 +893,7 @@ static const struct inode_operations nfs3_dir_inode_operations = {
|
|||
.mkdir = nfs_mkdir,
|
||||
.rmdir = nfs_rmdir,
|
||||
.mknod = nfs_mknod,
|
||||
.rename = nfs_rename,
|
||||
.rename2 = nfs_rename,
|
||||
.permission = nfs_permission,
|
||||
.getattr = nfs_getattr,
|
||||
.setattr = nfs_setattr,
|
||||
|
|
|
@ -8937,7 +8937,7 @@ static const struct inode_operations nfs4_dir_inode_operations = {
|
|||
.mkdir = nfs_mkdir,
|
||||
.rmdir = nfs_rmdir,
|
||||
.mknod = nfs_mknod,
|
||||
.rename = nfs_rename,
|
||||
.rename2 = nfs_rename,
|
||||
.permission = nfs_permission,
|
||||
.getattr = nfs_getattr,
|
||||
.setattr = nfs_setattr,
|
||||
|
|
|
@ -685,7 +685,7 @@ static const struct inode_operations nfs_dir_inode_operations = {
|
|||
.mkdir = nfs_mkdir,
|
||||
.rmdir = nfs_rmdir,
|
||||
.mknod = nfs_mknod,
|
||||
.rename = nfs_rename,
|
||||
.rename2 = nfs_rename,
|
||||
.permission = nfs_permission,
|
||||
.getattr = nfs_getattr,
|
||||
.setattr = nfs_setattr,
|
||||
|
|
|
@ -1203,7 +1203,8 @@ static void ocfs2_double_unlock(struct inode *inode1, struct inode *inode2)
|
|||
static int ocfs2_rename(struct inode *old_dir,
|
||||
struct dentry *old_dentry,
|
||||
struct inode *new_dir,
|
||||
struct dentry *new_dentry)
|
||||
struct dentry *new_dentry,
|
||||
unsigned int flags)
|
||||
{
|
||||
int status = 0, rename_lock = 0, parents_locked = 0, target_exists = 0;
|
||||
int old_child_locked = 0, new_child_locked = 0, update_dot_dot = 0;
|
||||
|
@ -1228,6 +1229,9 @@ static int ocfs2_rename(struct inode *old_dir,
|
|||
struct ocfs2_dir_lookup_result target_insert = { NULL, };
|
||||
bool should_add_orphan = false;
|
||||
|
||||
if (flags)
|
||||
return -EINVAL;
|
||||
|
||||
/* At some point it might be nice to break this function up a
|
||||
* bit. */
|
||||
|
||||
|
@ -2909,7 +2913,7 @@ const struct inode_operations ocfs2_dir_iops = {
|
|||
.symlink = ocfs2_symlink,
|
||||
.mkdir = ocfs2_mkdir,
|
||||
.mknod = ocfs2_mknod,
|
||||
.rename = ocfs2_rename,
|
||||
.rename2 = ocfs2_rename,
|
||||
.setattr = ocfs2_setattr,
|
||||
.getattr = ocfs2_getattr,
|
||||
.permission = ocfs2_permission,
|
||||
|
|
|
@ -409,11 +409,15 @@ out:
|
|||
static int orangefs_rename(struct inode *old_dir,
|
||||
struct dentry *old_dentry,
|
||||
struct inode *new_dir,
|
||||
struct dentry *new_dentry)
|
||||
struct dentry *new_dentry,
|
||||
unsigned int flags)
|
||||
{
|
||||
struct orangefs_kernel_op_s *new_op;
|
||||
int ret;
|
||||
|
||||
if (flags)
|
||||
return -EINVAL;
|
||||
|
||||
gossip_debug(GOSSIP_NAME_DEBUG,
|
||||
"orangefs_rename: called (%pd2 => %pd2) ct=%d\n",
|
||||
old_dentry, new_dentry, d_count(new_dentry));
|
||||
|
@ -459,7 +463,7 @@ const struct inode_operations orangefs_dir_inode_operations = {
|
|||
.symlink = orangefs_symlink,
|
||||
.mkdir = orangefs_mkdir,
|
||||
.rmdir = orangefs_unlink,
|
||||
.rename = orangefs_rename,
|
||||
.rename2 = orangefs_rename,
|
||||
.setattr = orangefs_setattr,
|
||||
.getattr = orangefs_getattr,
|
||||
.setxattr = generic_setxattr,
|
||||
|
|
Загрузка…
Ссылка в новой задаче