2015-07-17 17:38:13 +03:00
/*
* ( C ) 2001 Clemson University and The University of Chicago
*
* See COPYING in top - level directory .
*/
/*
* Linux VFS namei operations .
*/
# include "protocol.h"
2015-12-04 20:56:14 +03:00
# include "orangefs-kernel.h"
2015-07-17 17:38:13 +03:00
/*
* Get a newly allocated inode to go with a negative dentry .
*/
2015-11-24 23:12:14 +03:00
static int orangefs_create ( struct inode * dir ,
2015-07-17 17:38:13 +03:00
struct dentry * dentry ,
umode_t mode ,
bool exclusive )
{
2015-11-24 23:12:14 +03:00
struct orangefs_inode_s * parent = ORANGEFS_I ( dir ) ;
struct orangefs_kernel_op_s * new_op ;
2015-07-17 17:38:13 +03:00
struct inode * inode ;
int ret ;
2016-08-07 19:20:01 +03:00
gossip_debug ( GOSSIP_NAME_DEBUG , " %s: %pd \n " ,
2016-02-17 01:09:09 +03:00
__func__ ,
2016-08-07 19:20:01 +03:00
dentry ) ;
2015-07-17 17:38:13 +03:00
2015-11-24 23:12:14 +03:00
new_op = op_alloc ( ORANGEFS_VFS_OP_CREATE ) ;
2015-07-17 17:38:13 +03:00
if ( ! new_op )
return - ENOMEM ;
new_op - > upcall . req . create . parent_refn = parent - > refn ;
fill_default_sys_attrs ( new_op - > upcall . req . create . attributes ,
2015-11-24 23:12:14 +03:00
ORANGEFS_TYPE_METAFILE , mode ) ;
2015-07-17 17:38:13 +03:00
strncpy ( new_op - > upcall . req . create . d_name ,
2016-02-20 22:22:40 +03:00
dentry - > d_name . name , ORANGEFS_NAME_MAX ) ;
2015-07-17 17:38:13 +03:00
ret = service_operation ( new_op , __func__ , get_interruptible_flag ( dir ) ) ;
gossip_debug ( GOSSIP_NAME_DEBUG ,
2016-08-07 19:20:01 +03:00
" %s: %pd: handle:%pU: fsid:%d: new_op:%p: ret:%d: \n " ,
2016-02-17 01:09:09 +03:00
__func__ ,
2016-08-07 19:20:01 +03:00
dentry ,
2015-07-17 17:38:13 +03:00
& new_op - > downcall . resp . create . refn . khandle ,
2016-02-17 01:09:09 +03:00
new_op - > downcall . resp . create . refn . fs_id ,
new_op ,
ret ) ;
2015-07-17 17:38:13 +03:00
2016-02-17 01:09:09 +03:00
if ( ret < 0 )
2015-07-17 17:38:13 +03:00
goto out ;
2015-11-24 23:12:14 +03:00
inode = orangefs_new_inode ( dir - > i_sb , dir , S_IFREG | mode , 0 ,
2015-07-17 17:38:13 +03:00
& new_op - > downcall . resp . create . refn ) ;
if ( IS_ERR ( inode ) ) {
2016-08-07 19:20:01 +03:00
gossip_err ( " %s: Failed to allocate inode for file :%pd: \n " ,
2016-02-17 01:09:09 +03:00
__func__ ,
2016-08-07 19:20:01 +03:00
dentry ) ;
2015-07-17 17:38:13 +03:00
ret = PTR_ERR ( inode ) ;
goto out ;
}
gossip_debug ( GOSSIP_NAME_DEBUG ,
2016-08-07 19:20:01 +03:00
" %s: Assigned inode :%pU: for file :%pd: \n " ,
2016-02-17 01:09:09 +03:00
__func__ ,
get_khandle_from_ino ( inode ) ,
2016-08-07 19:20:01 +03:00
dentry ) ;
2015-07-17 17:38:13 +03:00
d_instantiate ( dentry , inode ) ;
unlock_new_inode ( inode ) ;
2016-10-17 11:14:23 +03:00
orangefs_set_timeout ( dentry ) ;
2016-07-28 21:46:36 +03:00
ORANGEFS_I ( inode ) - > getattr_time = jiffies - 1 ;
2015-07-17 17:38:13 +03:00
gossip_debug ( GOSSIP_NAME_DEBUG ,
2016-08-07 19:20:01 +03:00
" %s: dentry instantiated for %pd \n " ,
2016-02-17 01:09:09 +03:00
__func__ ,
2016-08-07 19:20:01 +03:00
dentry ) ;
2015-07-17 17:38:13 +03:00
SetMtimeFlag ( parent ) ;
2016-09-14 17:48:06 +03:00
dir - > i_mtime = dir - > i_ctime = current_time ( dir ) ;
2015-07-17 17:38:13 +03:00
mark_inode_dirty_sync ( dir ) ;
ret = 0 ;
out :
op_release ( new_op ) ;
2016-02-17 01:09:09 +03:00
gossip_debug ( GOSSIP_NAME_DEBUG ,
2016-08-07 19:20:01 +03:00
" %s: %pd: returning %d \n " ,
2016-02-17 01:09:09 +03:00
__func__ ,
2016-08-07 19:20:01 +03:00
dentry ,
2016-02-17 01:09:09 +03:00
ret ) ;
2015-07-17 17:38:13 +03:00
return ret ;
}
/*
* Attempt to resolve an object name ( dentry - > d_name ) , parent handle , and
* fsid into a handle for the object .
*/
2015-11-24 23:12:14 +03:00
static struct dentry * orangefs_lookup ( struct inode * dir , struct dentry * dentry ,
2015-07-17 17:38:13 +03:00
unsigned int flags )
{
2015-11-24 23:12:14 +03:00
struct orangefs_inode_s * parent = ORANGEFS_I ( dir ) ;
struct orangefs_kernel_op_s * new_op ;
2015-07-17 17:38:13 +03:00
struct inode * inode ;
struct dentry * res ;
int ret = - EINVAL ;
/*
* in theory we could skip a lookup here ( if the intent is to
* create ) in order to avoid a potentially failed lookup , but
* leaving it in can skip a valid lookup and try to create a file
* that already exists ( e . g . the vfs already handles checking for
* - EEXIST on O_EXCL opens , which is broken if we skip this lookup
* in the create path )
*/
2016-08-07 19:20:01 +03:00
gossip_debug ( GOSSIP_NAME_DEBUG , " %s called on %pd \n " ,
__func__ , dentry ) ;
2015-07-17 17:38:13 +03:00
2016-02-20 22:22:40 +03:00
if ( dentry - > d_name . len > ( ORANGEFS_NAME_MAX - 1 ) )
2015-07-17 17:38:13 +03:00
return ERR_PTR ( - ENAMETOOLONG ) ;
2015-11-24 23:12:14 +03:00
new_op = op_alloc ( ORANGEFS_VFS_OP_LOOKUP ) ;
2015-07-17 17:38:13 +03:00
if ( ! new_op )
return ERR_PTR ( - ENOMEM ) ;
2015-12-11 18:46:22 +03:00
new_op - > upcall . req . lookup . sym_follow = ORANGEFS_LOOKUP_LINK_NO_FOLLOW ;
2015-07-17 17:38:13 +03:00
gossip_debug ( GOSSIP_NAME_DEBUG , " %s:%s:%d using parent %pU \n " ,
__FILE__ ,
__func__ ,
__LINE__ ,
& parent - > refn . khandle ) ;
new_op - > upcall . req . lookup . parent_refn = parent - > refn ;
strncpy ( new_op - > upcall . req . lookup . d_name , dentry - > d_name . name ,
2016-02-20 22:22:40 +03:00
ORANGEFS_NAME_MAX ) ;
2015-07-17 17:38:13 +03:00
gossip_debug ( GOSSIP_NAME_DEBUG ,
2016-02-20 22:47:13 +03:00
" %s: doing lookup on %s under %pU,%d \n " ,
2015-07-17 17:38:13 +03:00
__func__ ,
new_op - > upcall . req . lookup . d_name ,
& new_op - > upcall . req . lookup . parent_refn . khandle ,
2016-02-20 22:47:13 +03:00
new_op - > upcall . req . lookup . parent_refn . fs_id ) ;
2015-07-17 17:38:13 +03:00
ret = service_operation ( new_op , __func__ , get_interruptible_flag ( dir ) ) ;
gossip_debug ( GOSSIP_NAME_DEBUG ,
" Lookup Got %pU, fsid %d (ret=%d) \n " ,
& new_op - > downcall . resp . lookup . refn . khandle ,
new_op - > downcall . resp . lookup . refn . fs_id ,
ret ) ;
if ( ret < 0 ) {
if ( ret = = - ENOENT ) {
/*
* if no inode was found , add a negative dentry to
* dcache anyway ; if we don ' t , we don ' t hold expected
* lookup semantics and we most noticeably break
* during directory renames .
*
* however , if the operation failed or exited , do not
* add the dentry ( e . g . in the case that a touch is
* issued on a file that already exists that was
* interrupted during this lookup - - no need to add
* another negative dentry for an existing file )
*/
gossip_debug ( GOSSIP_NAME_DEBUG ,
2015-11-24 23:12:14 +03:00
" orangefs_lookup: Adding *negative* dentry "
2016-08-07 19:20:01 +03:00
" %p for %pd \n " ,
2015-07-17 17:38:13 +03:00
dentry ,
2016-08-07 19:20:01 +03:00
dentry ) ;
2015-07-17 17:38:13 +03:00
d_add ( dentry , NULL ) ;
res = NULL ;
goto out ;
}
/* must be a non-recoverable error */
res = ERR_PTR ( ret ) ;
goto out ;
}
2016-10-17 11:14:23 +03:00
orangefs_set_timeout ( dentry ) ;
2016-02-09 01:01:29 +03:00
2015-11-24 23:12:14 +03:00
inode = orangefs_iget ( dir - > i_sb , & new_op - > downcall . resp . lookup . refn ) ;
2015-07-17 17:38:13 +03:00
if ( IS_ERR ( inode ) ) {
gossip_debug ( GOSSIP_NAME_DEBUG ,
" error %ld from iget \n " , PTR_ERR ( inode ) ) ;
res = ERR_CAST ( inode ) ;
goto out ;
}
2016-07-28 21:46:36 +03:00
ORANGEFS_I ( inode ) - > getattr_time = jiffies - 1 ;
2016-06-09 23:32:38 +03:00
2015-07-17 17:38:13 +03:00
gossip_debug ( GOSSIP_NAME_DEBUG ,
" %s:%s:%d "
" Found good inode [%lu] with count [%d] \n " ,
__FILE__ ,
__func__ ,
__LINE__ ,
inode - > i_ino ,
( int ) atomic_read ( & inode - > i_count ) ) ;
/* update dentry/inode pair into dcache */
res = d_splice_alias ( inode , dentry ) ;
gossip_debug ( GOSSIP_NAME_DEBUG ,
" Lookup success (inode ct = %d) \n " ,
( int ) atomic_read ( & inode - > i_count ) ) ;
out :
op_release ( new_op ) ;
return res ;
}
/* return 0 on success; non-zero otherwise */
2015-11-24 23:12:14 +03:00
static int orangefs_unlink ( struct inode * dir , struct dentry * dentry )
2015-07-17 17:38:13 +03:00
{
struct inode * inode = dentry - > d_inode ;
2015-11-24 23:12:14 +03:00
struct orangefs_inode_s * parent = ORANGEFS_I ( dir ) ;
struct orangefs_kernel_op_s * new_op ;
2015-07-17 17:38:13 +03:00
int ret ;
gossip_debug ( GOSSIP_NAME_DEBUG ,
2016-08-07 19:20:01 +03:00
" %s: called on %pd \n "
2015-07-17 17:38:13 +03:00
" (inode %pU): Parent is %pU | fs_id %d \n " ,
__func__ ,
2016-08-07 19:20:01 +03:00
dentry ,
2015-07-17 17:38:13 +03:00
get_khandle_from_ino ( inode ) ,
& parent - > refn . khandle ,
parent - > refn . fs_id ) ;
2015-11-24 23:12:14 +03:00
new_op = op_alloc ( ORANGEFS_VFS_OP_REMOVE ) ;
2015-07-17 17:38:13 +03:00
if ( ! new_op )
return - ENOMEM ;
new_op - > upcall . req . remove . parent_refn = parent - > refn ;
strncpy ( new_op - > upcall . req . remove . d_name , dentry - > d_name . name ,
2016-02-20 22:22:40 +03:00
ORANGEFS_NAME_MAX ) ;
2015-07-17 17:38:13 +03:00
2015-11-24 23:12:14 +03:00
ret = service_operation ( new_op , " orangefs_unlink " ,
2015-07-17 17:38:13 +03:00
get_interruptible_flag ( inode ) ) ;
2016-02-17 01:09:09 +03:00
gossip_debug ( GOSSIP_NAME_DEBUG ,
" %s: service_operation returned:%d: \n " ,
__func__ ,
ret ) ;
2015-07-17 17:38:13 +03:00
op_release ( new_op ) ;
if ( ! ret ) {
drop_nlink ( inode ) ;
SetMtimeFlag ( parent ) ;
2016-09-14 17:48:06 +03:00
dir - > i_mtime = dir - > i_ctime = current_time ( dir ) ;
2015-07-17 17:38:13 +03:00
mark_inode_dirty_sync ( dir ) ;
}
return ret ;
}
2015-11-24 23:12:14 +03:00
static int orangefs_symlink ( struct inode * dir ,
2015-07-17 17:38:13 +03:00
struct dentry * dentry ,
const char * symname )
{
2015-11-24 23:12:14 +03:00
struct orangefs_inode_s * parent = ORANGEFS_I ( dir ) ;
struct orangefs_kernel_op_s * new_op ;
2015-07-17 17:38:13 +03:00
struct inode * inode ;
int mode = 755 ;
int ret ;
gossip_debug ( GOSSIP_NAME_DEBUG , " %s: called \n " , __func__ ) ;
if ( ! symname )
return - EINVAL ;
2016-03-01 00:07:35 +03:00
if ( strlen ( symname ) + 1 > ORANGEFS_NAME_MAX )
return - ENAMETOOLONG ;
2015-11-24 23:12:14 +03:00
new_op = op_alloc ( ORANGEFS_VFS_OP_SYMLINK ) ;
2015-07-17 17:38:13 +03:00
if ( ! new_op )
return - ENOMEM ;
new_op - > upcall . req . sym . parent_refn = parent - > refn ;
fill_default_sys_attrs ( new_op - > upcall . req . sym . attributes ,
2015-11-24 23:12:14 +03:00
ORANGEFS_TYPE_SYMLINK ,
2015-07-17 17:38:13 +03:00
mode ) ;
strncpy ( new_op - > upcall . req . sym . entry_name ,
dentry - > d_name . name ,
2016-02-20 22:22:40 +03:00
ORANGEFS_NAME_MAX ) ;
strncpy ( new_op - > upcall . req . sym . target , symname , ORANGEFS_NAME_MAX ) ;
2015-07-17 17:38:13 +03:00
ret = service_operation ( new_op , __func__ , get_interruptible_flag ( dir ) ) ;
gossip_debug ( GOSSIP_NAME_DEBUG ,
2015-11-24 23:12:14 +03:00
" Symlink Got ORANGEFS handle %pU on fsid %d (ret=%d) \n " ,
2015-07-17 17:38:13 +03:00
& new_op - > downcall . resp . sym . refn . khandle ,
new_op - > downcall . resp . sym . refn . fs_id , ret ) ;
if ( ret < 0 ) {
gossip_debug ( GOSSIP_NAME_DEBUG ,
" %s: failed with error code %d \n " ,
__func__ , ret ) ;
goto out ;
}
2015-11-24 23:12:14 +03:00
inode = orangefs_new_inode ( dir - > i_sb , dir , S_IFLNK | mode , 0 ,
2015-07-17 17:38:13 +03:00
& new_op - > downcall . resp . sym . refn ) ;
if ( IS_ERR ( inode ) ) {
gossip_err
2015-11-24 23:12:14 +03:00
( " *** Failed to allocate orangefs symlink inode \n " ) ;
2015-07-17 17:38:13 +03:00
ret = PTR_ERR ( inode ) ;
goto out ;
}
gossip_debug ( GOSSIP_NAME_DEBUG ,
" Assigned symlink inode new number of %pU \n " ,
get_khandle_from_ino ( inode ) ) ;
d_instantiate ( dentry , inode ) ;
unlock_new_inode ( inode ) ;
2016-10-17 11:14:23 +03:00
orangefs_set_timeout ( dentry ) ;
2016-07-28 21:46:36 +03:00
ORANGEFS_I ( inode ) - > getattr_time = jiffies - 1 ;
2015-07-17 17:38:13 +03:00
gossip_debug ( GOSSIP_NAME_DEBUG ,
2016-08-07 19:20:01 +03:00
" Inode (Symlink) %pU -> %pd \n " ,
2015-07-17 17:38:13 +03:00
get_khandle_from_ino ( inode ) ,
2016-08-07 19:20:01 +03:00
dentry ) ;
2015-07-17 17:38:13 +03:00
SetMtimeFlag ( parent ) ;
2016-09-14 17:48:06 +03:00
dir - > i_mtime = dir - > i_ctime = current_time ( dir ) ;
2015-07-17 17:38:13 +03:00
mark_inode_dirty_sync ( dir ) ;
ret = 0 ;
out :
op_release ( new_op ) ;
return ret ;
}
2015-11-24 23:12:14 +03:00
static int orangefs_mkdir ( struct inode * dir , struct dentry * dentry , umode_t mode )
2015-07-17 17:38:13 +03:00
{
2015-11-24 23:12:14 +03:00
struct orangefs_inode_s * parent = ORANGEFS_I ( dir ) ;
struct orangefs_kernel_op_s * new_op ;
2015-07-17 17:38:13 +03:00
struct inode * inode ;
int ret ;
2015-11-24 23:12:14 +03:00
new_op = op_alloc ( ORANGEFS_VFS_OP_MKDIR ) ;
2015-07-17 17:38:13 +03:00
if ( ! new_op )
return - ENOMEM ;
new_op - > upcall . req . mkdir . parent_refn = parent - > refn ;
fill_default_sys_attrs ( new_op - > upcall . req . mkdir . attributes ,
2015-11-24 23:12:14 +03:00
ORANGEFS_TYPE_DIRECTORY , mode ) ;
2015-07-17 17:38:13 +03:00
strncpy ( new_op - > upcall . req . mkdir . d_name ,
2016-02-20 22:22:40 +03:00
dentry - > d_name . name , ORANGEFS_NAME_MAX ) ;
2015-07-17 17:38:13 +03:00
ret = service_operation ( new_op , __func__ , get_interruptible_flag ( dir ) ) ;
gossip_debug ( GOSSIP_NAME_DEBUG ,
2015-11-24 23:12:14 +03:00
" Mkdir Got ORANGEFS handle %pU on fsid %d \n " ,
2015-07-17 17:38:13 +03:00
& new_op - > downcall . resp . mkdir . refn . khandle ,
new_op - > downcall . resp . mkdir . refn . fs_id ) ;
if ( ret < 0 ) {
gossip_debug ( GOSSIP_NAME_DEBUG ,
" %s: failed with error code %d \n " ,
__func__ , ret ) ;
goto out ;
}
2015-11-24 23:12:14 +03:00
inode = orangefs_new_inode ( dir - > i_sb , dir , S_IFDIR | mode , 0 ,
2015-07-17 17:38:13 +03:00
& new_op - > downcall . resp . mkdir . refn ) ;
if ( IS_ERR ( inode ) ) {
2015-11-24 23:12:14 +03:00
gossip_err ( " *** Failed to allocate orangefs dir inode \n " ) ;
2015-07-17 17:38:13 +03:00
ret = PTR_ERR ( inode ) ;
goto out ;
}
gossip_debug ( GOSSIP_NAME_DEBUG ,
" Assigned dir inode new number of %pU \n " ,
get_khandle_from_ino ( inode ) ) ;
d_instantiate ( dentry , inode ) ;
unlock_new_inode ( inode ) ;
2016-10-17 11:14:23 +03:00
orangefs_set_timeout ( dentry ) ;
2016-07-28 21:46:36 +03:00
ORANGEFS_I ( inode ) - > getattr_time = jiffies - 1 ;
2015-07-17 17:38:13 +03:00
gossip_debug ( GOSSIP_NAME_DEBUG ,
2016-08-07 19:20:01 +03:00
" Inode (Directory) %pU -> %pd \n " ,
2015-07-17 17:38:13 +03:00
get_khandle_from_ino ( inode ) ,
2016-08-07 19:20:01 +03:00
dentry ) ;
2015-07-17 17:38:13 +03:00
/*
* NOTE : we have no good way to keep nlink consistent for directories
* across clients ; keep constant at 1.
*/
SetMtimeFlag ( parent ) ;
2016-09-14 17:48:06 +03:00
dir - > i_mtime = dir - > i_ctime = current_time ( dir ) ;
2015-07-17 17:38:13 +03:00
mark_inode_dirty_sync ( dir ) ;
out :
op_release ( new_op ) ;
return ret ;
}
2015-11-24 23:12:14 +03:00
static int orangefs_rename ( struct inode * old_dir ,
2015-07-17 17:38:13 +03:00
struct dentry * old_dentry ,
struct inode * new_dir ,
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>
2016-09-27 12:03:58 +03:00
struct dentry * new_dentry ,
unsigned int flags )
2015-07-17 17:38:13 +03:00
{
2015-11-24 23:12:14 +03:00
struct orangefs_kernel_op_s * new_op ;
2015-07-17 17:38:13 +03:00
int ret ;
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>
2016-09-27 12:03:58 +03:00
if ( flags )
return - EINVAL ;
2015-07-17 17:38:13 +03:00
gossip_debug ( GOSSIP_NAME_DEBUG ,
2016-05-29 22:00:34 +03:00
" orangefs_rename: called (%pd2 => %pd2) ct=%d \n " ,
old_dentry , new_dentry , d_count ( new_dentry ) ) ;
2015-07-17 17:38:13 +03:00
2016-07-28 21:46:36 +03:00
ORANGEFS_I ( new_dentry - > d_parent - > d_inode ) - > getattr_time = jiffies - 1 ;
2016-06-09 23:32:38 +03:00
2015-11-24 23:12:14 +03:00
new_op = op_alloc ( ORANGEFS_VFS_OP_RENAME ) ;
2015-07-17 17:38:13 +03:00
if ( ! new_op )
return - EINVAL ;
2015-11-24 23:12:14 +03:00
new_op - > upcall . req . rename . old_parent_refn = ORANGEFS_I ( old_dir ) - > refn ;
new_op - > upcall . req . rename . new_parent_refn = ORANGEFS_I ( new_dir ) - > refn ;
2015-07-17 17:38:13 +03:00
strncpy ( new_op - > upcall . req . rename . d_old_name ,
old_dentry - > d_name . name ,
2016-02-20 22:22:40 +03:00
ORANGEFS_NAME_MAX ) ;
2015-07-17 17:38:13 +03:00
strncpy ( new_op - > upcall . req . rename . d_new_name ,
new_dentry - > d_name . name ,
2016-02-20 22:22:40 +03:00
ORANGEFS_NAME_MAX ) ;
2015-07-17 17:38:13 +03:00
ret = service_operation ( new_op ,
2015-11-24 23:12:14 +03:00
" orangefs_rename " ,
2015-07-17 17:38:13 +03:00
get_interruptible_flag ( old_dentry - > d_inode ) ) ;
gossip_debug ( GOSSIP_NAME_DEBUG ,
2015-11-24 23:12:14 +03:00
" orangefs_rename: got downcall status %d \n " ,
2015-07-17 17:38:13 +03:00
ret ) ;
if ( new_dentry - > d_inode )
2016-09-14 17:48:06 +03:00
new_dentry - > d_inode - > i_ctime = current_time ( new_dentry - > d_inode ) ;
2015-07-17 17:38:13 +03:00
op_release ( new_op ) ;
return ret ;
}
2015-11-24 23:12:14 +03:00
/* ORANGEFS implementation of VFS inode operations for directories */
2016-05-15 01:46:32 +03:00
const struct inode_operations orangefs_dir_inode_operations = {
2015-11-24 23:12:14 +03:00
. lookup = orangefs_lookup ,
. get_acl = orangefs_get_acl ,
. set_acl = orangefs_set_acl ,
. create = orangefs_create ,
. unlink = orangefs_unlink ,
. symlink = orangefs_symlink ,
. mkdir = orangefs_mkdir ,
. rmdir = orangefs_unlink ,
. rename = orangefs_rename ,
. setattr = orangefs_setattr ,
. getattr = orangefs_getattr ,
. listxattr = orangefs_listxattr ,
2016-01-30 21:46:54 +03:00
. permission = orangefs_permission ,
2015-07-17 17:38:13 +03:00
} ;