2012-11-29 08:28:09 +04:00
/*
2012-11-02 12:11:10 +04:00
* fs / f2fs / namei . c
*
* Copyright ( c ) 2012 Samsung Electronics Co . , Ltd .
* http : //www.samsung.com/
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation .
*/
# include <linux/fs.h>
# include <linux/f2fs_fs.h>
# include <linux/pagemap.h>
# include <linux/sched.h>
# include <linux/ctype.h>
2014-06-19 12:23:19 +04:00
# include <linux/dcache.h>
2015-04-15 23:49:55 +03:00
# include <linux/namei.h>
2012-11-02 12:11:10 +04:00
# include "f2fs.h"
2013-03-21 10:21:57 +04:00
# include "node.h"
2012-11-02 12:11:10 +04:00
# include "xattr.h"
# include "acl.h"
2013-04-19 20:28:40 +04:00
# include <trace/events/f2fs.h>
2012-11-02 12:11:10 +04:00
static struct inode * f2fs_new_inode ( struct inode * dir , umode_t mode )
{
2014-09-03 02:31:18 +04:00
struct f2fs_sb_info * sbi = F2FS_I_SB ( dir ) ;
2012-11-02 12:11:10 +04:00
nid_t ino ;
struct inode * inode ;
bool nid_free = false ;
f2fs: use rw_sem instead of fs_lock(locks mutex)
The fs_locks is used to block other ops(ex, recovery) when doing checkpoint.
And each other operate routine(besides checkpoint) needs to acquire a fs_lock,
there is a terrible problem here, if these are too many concurrency threads acquiring
fs_lock, so that they will block each other and may lead to some performance problem,
but this is not the phenomenon we want to see.
Though there are some optimization patches introduced to enhance the usage of fs_lock,
but the thorough solution is using a *rw_sem* to replace the fs_lock.
Checkpoint routine takes write_sem, and other ops take read_sem, so that we can block
other ops(ex, recovery) when doing checkpoint, and other ops will not disturb each other,
this can avoid the problem described above completely.
Because of the weakness of rw_sem, the above change may introduce a potential problem
that the checkpoint thread might get starved if other threads are intensively locking
the read semaphore for I/O.(Pointed out by Xu Jin)
In order to avoid this, a wait_list is introduced, the appending read semaphore ops
will be dropped into the wait_list if checkpoint thread is waiting for write semaphore,
and will be waked up when checkpoint thread gives up write semaphore.
Thanks to Kim's previous review and test, and will be very glad to see other guys'
performance tests about this patch.
V2:
-fix the potential starvation problem.
-use more suitable func name suggested by Xu Jin.
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
[Jaegeuk Kim: adjust minor coding standard]
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-09-27 14:08:30 +04:00
int err ;
2012-11-02 12:11:10 +04:00
2014-06-21 08:44:02 +04:00
inode = new_inode ( dir - > i_sb ) ;
2012-11-02 12:11:10 +04:00
if ( ! inode )
return ERR_PTR ( - ENOMEM ) ;
f2fs: use rw_sem instead of fs_lock(locks mutex)
The fs_locks is used to block other ops(ex, recovery) when doing checkpoint.
And each other operate routine(besides checkpoint) needs to acquire a fs_lock,
there is a terrible problem here, if these are too many concurrency threads acquiring
fs_lock, so that they will block each other and may lead to some performance problem,
but this is not the phenomenon we want to see.
Though there are some optimization patches introduced to enhance the usage of fs_lock,
but the thorough solution is using a *rw_sem* to replace the fs_lock.
Checkpoint routine takes write_sem, and other ops take read_sem, so that we can block
other ops(ex, recovery) when doing checkpoint, and other ops will not disturb each other,
this can avoid the problem described above completely.
Because of the weakness of rw_sem, the above change may introduce a potential problem
that the checkpoint thread might get starved if other threads are intensively locking
the read semaphore for I/O.(Pointed out by Xu Jin)
In order to avoid this, a wait_list is introduced, the appending read semaphore ops
will be dropped into the wait_list if checkpoint thread is waiting for write semaphore,
and will be waked up when checkpoint thread gives up write semaphore.
Thanks to Kim's previous review and test, and will be very glad to see other guys'
performance tests about this patch.
V2:
-fix the potential starvation problem.
-use more suitable func name suggested by Xu Jin.
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
[Jaegeuk Kim: adjust minor coding standard]
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-09-27 14:08:30 +04:00
f2fs_lock_op ( sbi ) ;
2012-11-02 12:11:10 +04:00
if ( ! alloc_nid ( sbi , & ino ) ) {
f2fs: use rw_sem instead of fs_lock(locks mutex)
The fs_locks is used to block other ops(ex, recovery) when doing checkpoint.
And each other operate routine(besides checkpoint) needs to acquire a fs_lock,
there is a terrible problem here, if these are too many concurrency threads acquiring
fs_lock, so that they will block each other and may lead to some performance problem,
but this is not the phenomenon we want to see.
Though there are some optimization patches introduced to enhance the usage of fs_lock,
but the thorough solution is using a *rw_sem* to replace the fs_lock.
Checkpoint routine takes write_sem, and other ops take read_sem, so that we can block
other ops(ex, recovery) when doing checkpoint, and other ops will not disturb each other,
this can avoid the problem described above completely.
Because of the weakness of rw_sem, the above change may introduce a potential problem
that the checkpoint thread might get starved if other threads are intensively locking
the read semaphore for I/O.(Pointed out by Xu Jin)
In order to avoid this, a wait_list is introduced, the appending read semaphore ops
will be dropped into the wait_list if checkpoint thread is waiting for write semaphore,
and will be waked up when checkpoint thread gives up write semaphore.
Thanks to Kim's previous review and test, and will be very glad to see other guys'
performance tests about this patch.
V2:
-fix the potential starvation problem.
-use more suitable func name suggested by Xu Jin.
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
[Jaegeuk Kim: adjust minor coding standard]
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-09-27 14:08:30 +04:00
f2fs_unlock_op ( sbi ) ;
2012-11-02 12:11:10 +04:00
err = - ENOSPC ;
goto fail ;
}
f2fs: use rw_sem instead of fs_lock(locks mutex)
The fs_locks is used to block other ops(ex, recovery) when doing checkpoint.
And each other operate routine(besides checkpoint) needs to acquire a fs_lock,
there is a terrible problem here, if these are too many concurrency threads acquiring
fs_lock, so that they will block each other and may lead to some performance problem,
but this is not the phenomenon we want to see.
Though there are some optimization patches introduced to enhance the usage of fs_lock,
but the thorough solution is using a *rw_sem* to replace the fs_lock.
Checkpoint routine takes write_sem, and other ops take read_sem, so that we can block
other ops(ex, recovery) when doing checkpoint, and other ops will not disturb each other,
this can avoid the problem described above completely.
Because of the weakness of rw_sem, the above change may introduce a potential problem
that the checkpoint thread might get starved if other threads are intensively locking
the read semaphore for I/O.(Pointed out by Xu Jin)
In order to avoid this, a wait_list is introduced, the appending read semaphore ops
will be dropped into the wait_list if checkpoint thread is waiting for write semaphore,
and will be waked up when checkpoint thread gives up write semaphore.
Thanks to Kim's previous review and test, and will be very glad to see other guys'
performance tests about this patch.
V2:
-fix the potential starvation problem.
-use more suitable func name suggested by Xu Jin.
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
[Jaegeuk Kim: adjust minor coding standard]
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-09-27 14:08:30 +04:00
f2fs_unlock_op ( sbi ) ;
2012-11-02 12:11:10 +04:00
2014-05-08 13:09:30 +04:00
inode_init_owner ( inode , dir , mode ) ;
2012-11-02 12:11:10 +04:00
inode - > i_ino = ino ;
inode - > i_blocks = 0 ;
inode - > i_mtime = inode - > i_atime = inode - > i_ctime = CURRENT_TIME ;
inode - > i_generation = sbi - > s_next_generation + + ;
err = insert_inode_locked ( inode ) ;
if ( err ) {
err = - EINVAL ;
nid_free = true ;
2015-08-16 22:38:15 +03:00
goto fail ;
2012-11-02 12:11:10 +04:00
}
2014-09-24 14:19:10 +04:00
2015-04-22 06:39:58 +03:00
/* If the directory encrypted, then we should encrypt the inode. */
if ( f2fs_encrypted_inode ( dir ) & & f2fs_may_encrypt ( inode ) )
f2fs_set_encrypted_inode ( inode ) ;
2015-12-23 12:51:35 +03:00
if ( test_opt ( sbi , INLINE_DATA ) & & f2fs_may_inline_data ( inode ) )
2014-10-24 06:48:09 +04:00
set_inode_flag ( F2FS_I ( inode ) , FI_INLINE_DATA ) ;
2015-04-23 20:27:21 +03:00
if ( f2fs_may_inline_dentry ( inode ) )
2014-09-24 14:19:10 +04:00
set_inode_flag ( F2FS_I ( inode ) , FI_INLINE_DENTRY ) ;
2015-06-20 03:53:26 +03:00
f2fs_init_extent_tree ( inode , NULL ) ;
2015-07-15 12:28:53 +03:00
stat_inc_inline_xattr ( inode ) ;
2015-05-01 04:58:22 +03:00
stat_inc_inline_inode ( inode ) ;
stat_inc_inline_dir ( inode ) ;
2013-04-25 08:24:33 +04:00
trace_f2fs_new_inode ( inode , 0 ) ;
2012-11-02 12:11:10 +04:00
mark_inode_dirty ( inode ) ;
return inode ;
fail :
2013-04-25 08:24:33 +04:00
trace_f2fs_new_inode ( inode , err ) ;
2013-04-30 06:33:27 +04:00
make_bad_inode ( inode ) ;
2012-11-02 12:11:10 +04:00
if ( nid_free )
2015-06-23 20:36:08 +03:00
set_inode_flag ( F2FS_I ( inode ) , FI_FREE_NID ) ;
iput ( inode ) ;
2012-11-02 12:11:10 +04:00
return ERR_PTR ( err ) ;
}
static int is_multimedia_file ( const unsigned char * s , const char * sub )
{
2012-12-27 21:55:46 +04:00
size_t slen = strlen ( s ) ;
size_t sublen = strlen ( sub ) ;
2012-11-02 12:11:10 +04:00
2015-07-06 15:30:40 +03:00
/*
* filename format of multimedia file should be defined as :
* " filename + '.' + extension " .
*/
if ( slen < sublen + 2 )
return 0 ;
if ( s [ slen - sublen - 1 ] ! = ' . ' )
2013-04-19 20:27:21 +04:00
return 0 ;
2012-11-02 12:11:10 +04:00
2013-08-22 14:11:25 +04:00
return ! strncasecmp ( s + slen - sublen , sub , sublen ) ;
2012-11-02 12:11:10 +04:00
}
2012-11-29 08:28:09 +04:00
/*
2012-11-02 12:11:10 +04:00
* Set multimedia files as cold files for hot / cold data separation
*/
2013-03-21 10:21:57 +04:00
static inline void set_cold_files ( struct f2fs_sb_info * sbi , struct inode * inode ,
2012-11-02 12:11:10 +04:00
const unsigned char * name )
{
int i ;
__u8 ( * extlist ) [ 8 ] = sbi - > raw_super - > extension_list ;
int count = le32_to_cpu ( sbi - > raw_super - > extension_count ) ;
for ( i = 0 ; i < count ; i + + ) {
2013-04-19 20:27:21 +04:00
if ( is_multimedia_file ( name , extlist [ i ] ) ) {
2013-06-14 03:52:35 +04:00
file_set_cold ( inode ) ;
2012-11-02 12:11:10 +04:00
break ;
}
}
}
static int f2fs_create ( struct inode * dir , struct dentry * dentry , umode_t mode ,
bool excl )
{
2014-09-03 02:31:18 +04:00
struct f2fs_sb_info * sbi = F2FS_I_SB ( dir ) ;
2012-11-02 12:11:10 +04:00
struct inode * inode ;
nid_t ino = 0 ;
f2fs: use rw_sem instead of fs_lock(locks mutex)
The fs_locks is used to block other ops(ex, recovery) when doing checkpoint.
And each other operate routine(besides checkpoint) needs to acquire a fs_lock,
there is a terrible problem here, if these are too many concurrency threads acquiring
fs_lock, so that they will block each other and may lead to some performance problem,
but this is not the phenomenon we want to see.
Though there are some optimization patches introduced to enhance the usage of fs_lock,
but the thorough solution is using a *rw_sem* to replace the fs_lock.
Checkpoint routine takes write_sem, and other ops take read_sem, so that we can block
other ops(ex, recovery) when doing checkpoint, and other ops will not disturb each other,
this can avoid the problem described above completely.
Because of the weakness of rw_sem, the above change may introduce a potential problem
that the checkpoint thread might get starved if other threads are intensively locking
the read semaphore for I/O.(Pointed out by Xu Jin)
In order to avoid this, a wait_list is introduced, the appending read semaphore ops
will be dropped into the wait_list if checkpoint thread is waiting for write semaphore,
and will be waked up when checkpoint thread gives up write semaphore.
Thanks to Kim's previous review and test, and will be very glad to see other guys'
performance tests about this patch.
V2:
-fix the potential starvation problem.
-use more suitable func name suggested by Xu Jin.
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
[Jaegeuk Kim: adjust minor coding standard]
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-09-27 14:08:30 +04:00
int err ;
2012-11-02 12:11:10 +04:00
inode = f2fs_new_inode ( dir , mode ) ;
if ( IS_ERR ( inode ) )
return PTR_ERR ( inode ) ;
if ( ! test_opt ( sbi , DISABLE_EXT_IDENTIFY ) )
2013-03-21 10:21:57 +04:00
set_cold_files ( sbi , inode , dentry - > d_name . name ) ;
2012-11-02 12:11:10 +04:00
inode - > i_op = & f2fs_file_inode_operations ;
inode - > i_fop = & f2fs_file_operations ;
inode - > i_mapping - > a_ops = & f2fs_dblock_aops ;
ino = inode - > i_ino ;
2015-12-22 22:56:08 +03:00
f2fs_balance_fs ( sbi ) ;
f2fs: use rw_sem instead of fs_lock(locks mutex)
The fs_locks is used to block other ops(ex, recovery) when doing checkpoint.
And each other operate routine(besides checkpoint) needs to acquire a fs_lock,
there is a terrible problem here, if these are too many concurrency threads acquiring
fs_lock, so that they will block each other and may lead to some performance problem,
but this is not the phenomenon we want to see.
Though there are some optimization patches introduced to enhance the usage of fs_lock,
but the thorough solution is using a *rw_sem* to replace the fs_lock.
Checkpoint routine takes write_sem, and other ops take read_sem, so that we can block
other ops(ex, recovery) when doing checkpoint, and other ops will not disturb each other,
this can avoid the problem described above completely.
Because of the weakness of rw_sem, the above change may introduce a potential problem
that the checkpoint thread might get starved if other threads are intensively locking
the read semaphore for I/O.(Pointed out by Xu Jin)
In order to avoid this, a wait_list is introduced, the appending read semaphore ops
will be dropped into the wait_list if checkpoint thread is waiting for write semaphore,
and will be waked up when checkpoint thread gives up write semaphore.
Thanks to Kim's previous review and test, and will be very glad to see other guys'
performance tests about this patch.
V2:
-fix the potential starvation problem.
-use more suitable func name suggested by Xu Jin.
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
[Jaegeuk Kim: adjust minor coding standard]
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-09-27 14:08:30 +04:00
f2fs_lock_op ( sbi ) ;
2012-11-02 12:11:10 +04:00
err = f2fs_add_link ( dentry , inode ) ;
if ( err )
goto out ;
2014-09-25 22:55:53 +04:00
f2fs_unlock_op ( sbi ) ;
2012-11-02 12:11:10 +04:00
alloc_nid_done ( sbi , ino ) ;
2013-05-16 03:57:43 +04:00
d_instantiate ( dentry , inode ) ;
2012-11-02 12:11:10 +04:00
unlock_new_inode ( inode ) ;
2014-11-10 09:15:31 +03:00
if ( IS_DIRSYNC ( dir ) )
f2fs_sync_fs ( sbi - > sb , 1 ) ;
2012-11-02 12:11:10 +04:00
return 0 ;
out :
2014-09-25 22:55:53 +04:00
handle_failed_inode ( inode ) ;
2012-11-02 12:11:10 +04:00
return err ;
}
static int f2fs_link ( struct dentry * old_dentry , struct inode * dir ,
struct dentry * dentry )
{
2015-03-18 01:25:59 +03:00
struct inode * inode = d_inode ( old_dentry ) ;
2014-09-03 02:31:18 +04:00
struct f2fs_sb_info * sbi = F2FS_I_SB ( dir ) ;
f2fs: use rw_sem instead of fs_lock(locks mutex)
The fs_locks is used to block other ops(ex, recovery) when doing checkpoint.
And each other operate routine(besides checkpoint) needs to acquire a fs_lock,
there is a terrible problem here, if these are too many concurrency threads acquiring
fs_lock, so that they will block each other and may lead to some performance problem,
but this is not the phenomenon we want to see.
Though there are some optimization patches introduced to enhance the usage of fs_lock,
but the thorough solution is using a *rw_sem* to replace the fs_lock.
Checkpoint routine takes write_sem, and other ops take read_sem, so that we can block
other ops(ex, recovery) when doing checkpoint, and other ops will not disturb each other,
this can avoid the problem described above completely.
Because of the weakness of rw_sem, the above change may introduce a potential problem
that the checkpoint thread might get starved if other threads are intensively locking
the read semaphore for I/O.(Pointed out by Xu Jin)
In order to avoid this, a wait_list is introduced, the appending read semaphore ops
will be dropped into the wait_list if checkpoint thread is waiting for write semaphore,
and will be waked up when checkpoint thread gives up write semaphore.
Thanks to Kim's previous review and test, and will be very glad to see other guys'
performance tests about this patch.
V2:
-fix the potential starvation problem.
-use more suitable func name suggested by Xu Jin.
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
[Jaegeuk Kim: adjust minor coding standard]
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-09-27 14:08:30 +04:00
int err ;
2012-11-02 12:11:10 +04:00
2015-04-22 06:39:58 +03:00
if ( f2fs_encrypted_inode ( dir ) & &
! f2fs_is_child_context_consistent_with_parent ( dir , inode ) )
return - EPERM ;
2012-12-19 11:25:21 +04:00
f2fs_balance_fs ( sbi ) ;
2012-11-02 12:11:10 +04:00
inode - > i_ctime = CURRENT_TIME ;
2013-05-22 07:06:26 +04:00
ihold ( inode ) ;
2012-11-02 12:11:10 +04:00
set_inode_flag ( F2FS_I ( inode ) , FI_INC_LINK ) ;
f2fs: use rw_sem instead of fs_lock(locks mutex)
The fs_locks is used to block other ops(ex, recovery) when doing checkpoint.
And each other operate routine(besides checkpoint) needs to acquire a fs_lock,
there is a terrible problem here, if these are too many concurrency threads acquiring
fs_lock, so that they will block each other and may lead to some performance problem,
but this is not the phenomenon we want to see.
Though there are some optimization patches introduced to enhance the usage of fs_lock,
but the thorough solution is using a *rw_sem* to replace the fs_lock.
Checkpoint routine takes write_sem, and other ops take read_sem, so that we can block
other ops(ex, recovery) when doing checkpoint, and other ops will not disturb each other,
this can avoid the problem described above completely.
Because of the weakness of rw_sem, the above change may introduce a potential problem
that the checkpoint thread might get starved if other threads are intensively locking
the read semaphore for I/O.(Pointed out by Xu Jin)
In order to avoid this, a wait_list is introduced, the appending read semaphore ops
will be dropped into the wait_list if checkpoint thread is waiting for write semaphore,
and will be waked up when checkpoint thread gives up write semaphore.
Thanks to Kim's previous review and test, and will be very glad to see other guys'
performance tests about this patch.
V2:
-fix the potential starvation problem.
-use more suitable func name suggested by Xu Jin.
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
[Jaegeuk Kim: adjust minor coding standard]
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-09-27 14:08:30 +04:00
f2fs_lock_op ( sbi ) ;
2012-11-02 12:11:10 +04:00
err = f2fs_add_link ( dentry , inode ) ;
if ( err )
goto out ;
2014-09-25 22:55:53 +04:00
f2fs_unlock_op ( sbi ) ;
2012-11-02 12:11:10 +04:00
d_instantiate ( dentry , inode ) ;
2014-11-10 09:15:31 +03:00
if ( IS_DIRSYNC ( dir ) )
f2fs_sync_fs ( sbi - > sb , 1 ) ;
2012-11-02 12:11:10 +04:00
return 0 ;
out :
clear_inode_flag ( F2FS_I ( inode ) , FI_INC_LINK ) ;
iput ( inode ) ;
2014-09-25 22:55:53 +04:00
f2fs_unlock_op ( sbi ) ;
2012-11-02 12:11:10 +04:00
return err ;
}
struct dentry * f2fs_get_parent ( struct dentry * child )
{
struct qstr dotdot = QSTR_INIT ( " .. " , 2 ) ;
2015-03-18 01:25:59 +03:00
unsigned long ino = f2fs_inode_by_name ( d_inode ( child ) , & dotdot ) ;
2012-11-02 12:11:10 +04:00
if ( ! ino )
return ERR_PTR ( - ENOENT ) ;
2015-03-18 01:25:59 +03:00
return d_obtain_alias ( f2fs_iget ( d_inode ( child ) - > i_sb , ino ) ) ;
2012-11-02 12:11:10 +04:00
}
2015-03-31 01:07:16 +03:00
static int __recover_dot_dentries ( struct inode * dir , nid_t pino )
{
struct f2fs_sb_info * sbi = F2FS_I_SB ( dir ) ;
struct qstr dot = QSTR_INIT ( " . " , 1 ) ;
struct qstr dotdot = QSTR_INIT ( " .. " , 2 ) ;
struct f2fs_dir_entry * de ;
struct page * page ;
int err = 0 ;
2015-12-24 13:03:29 +03:00
f2fs_balance_fs ( sbi ) ;
2015-03-31 01:07:16 +03:00
f2fs_lock_op ( sbi ) ;
de = f2fs_find_entry ( dir , & dot , & page ) ;
if ( de ) {
f2fs_dentry_kunmap ( dir , page ) ;
f2fs_put_page ( page , 0 ) ;
} else {
err = __f2fs_add_link ( dir , & dot , NULL , dir - > i_ino , S_IFDIR ) ;
if ( err )
goto out ;
}
de = f2fs_find_entry ( dir , & dotdot , & page ) ;
if ( de ) {
f2fs_dentry_kunmap ( dir , page ) ;
f2fs_put_page ( page , 0 ) ;
} else {
err = __f2fs_add_link ( dir , & dotdot , NULL , pino , S_IFDIR ) ;
}
out :
if ( ! err ) {
clear_inode_flag ( F2FS_I ( dir ) , FI_INLINE_DOTS ) ;
mark_inode_dirty ( dir ) ;
}
f2fs_unlock_op ( sbi ) ;
return err ;
}
2012-11-02 12:11:10 +04:00
static struct dentry * f2fs_lookup ( struct inode * dir , struct dentry * dentry ,
unsigned int flags )
{
struct inode * inode = NULL ;
struct f2fs_dir_entry * de ;
struct page * page ;
2015-04-22 21:40:27 +03:00
nid_t ino ;
2015-04-22 06:39:58 +03:00
int err = 0 ;
2012-11-02 12:11:10 +04:00
2013-03-03 08:58:05 +04:00
if ( dentry - > d_name . len > F2FS_NAME_LEN )
2012-11-02 12:11:10 +04:00
return ERR_PTR ( - ENAMETOOLONG ) ;
de = f2fs_find_entry ( dir , & dentry - > d_name , & page ) ;
2015-04-22 21:40:27 +03:00
if ( ! de )
return d_splice_alias ( inode , dentry ) ;
2012-11-02 12:11:10 +04:00
2015-04-22 21:40:27 +03:00
ino = le32_to_cpu ( de - > ino ) ;
f2fs_dentry_kunmap ( dir , page ) ;
f2fs_put_page ( page , 0 ) ;
2015-03-31 01:07:16 +03:00
2015-04-22 21:40:27 +03:00
inode = f2fs_iget ( dir - > i_sb , ino ) ;
if ( IS_ERR ( inode ) )
return ERR_CAST ( inode ) ;
2015-03-31 01:07:16 +03:00
2015-04-22 06:39:58 +03:00
if ( f2fs_has_inline_dots ( inode ) ) {
2015-04-22 21:40:27 +03:00
err = __recover_dot_dentries ( inode , dir - > i_ino ) ;
2015-04-22 06:39:58 +03:00
if ( err )
goto err_out ;
2012-11-02 12:11:10 +04:00
}
return d_splice_alias ( inode , dentry ) ;
2015-04-22 06:39:58 +03:00
err_out :
iget_failed ( inode ) ;
return ERR_PTR ( err ) ;
2012-11-02 12:11:10 +04:00
}
static int f2fs_unlink ( struct inode * dir , struct dentry * dentry )
{
2014-09-03 02:31:18 +04:00
struct f2fs_sb_info * sbi = F2FS_I_SB ( dir ) ;
2015-03-18 01:25:59 +03:00
struct inode * inode = d_inode ( dentry ) ;
2012-11-02 12:11:10 +04:00
struct f2fs_dir_entry * de ;
struct page * page ;
int err = - ENOENT ;
2013-04-19 20:28:40 +04:00
trace_f2fs_unlink_enter ( dir , dentry ) ;
2012-12-19 11:25:21 +04:00
2012-11-02 12:11:10 +04:00
de = f2fs_find_entry ( dir , & dentry - > d_name , & page ) ;
if ( ! de )
goto fail ;
2015-12-22 22:56:08 +03:00
f2fs_balance_fs ( sbi ) ;
2013-10-08 05:19:28 +04:00
f2fs_lock_op ( sbi ) ;
2013-07-30 06:36:53 +04:00
err = acquire_orphan_inode ( sbi ) ;
2012-11-02 12:11:10 +04:00
if ( err ) {
2013-10-08 05:19:28 +04:00
f2fs_unlock_op ( sbi ) ;
2014-11-22 03:36:28 +03:00
f2fs_dentry_kunmap ( dir , page ) ;
2012-11-02 12:11:10 +04:00
f2fs_put_page ( page , 0 ) ;
goto fail ;
}
2014-09-24 14:17:04 +04:00
f2fs_delete_entry ( de , page , dir , inode ) ;
f2fs: use rw_sem instead of fs_lock(locks mutex)
The fs_locks is used to block other ops(ex, recovery) when doing checkpoint.
And each other operate routine(besides checkpoint) needs to acquire a fs_lock,
there is a terrible problem here, if these are too many concurrency threads acquiring
fs_lock, so that they will block each other and may lead to some performance problem,
but this is not the phenomenon we want to see.
Though there are some optimization patches introduced to enhance the usage of fs_lock,
but the thorough solution is using a *rw_sem* to replace the fs_lock.
Checkpoint routine takes write_sem, and other ops take read_sem, so that we can block
other ops(ex, recovery) when doing checkpoint, and other ops will not disturb each other,
this can avoid the problem described above completely.
Because of the weakness of rw_sem, the above change may introduce a potential problem
that the checkpoint thread might get starved if other threads are intensively locking
the read semaphore for I/O.(Pointed out by Xu Jin)
In order to avoid this, a wait_list is introduced, the appending read semaphore ops
will be dropped into the wait_list if checkpoint thread is waiting for write semaphore,
and will be waked up when checkpoint thread gives up write semaphore.
Thanks to Kim's previous review and test, and will be very glad to see other guys'
performance tests about this patch.
V2:
-fix the potential starvation problem.
-use more suitable func name suggested by Xu Jin.
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
[Jaegeuk Kim: adjust minor coding standard]
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-09-27 14:08:30 +04:00
f2fs_unlock_op ( sbi ) ;
2012-11-02 12:11:10 +04:00
2014-08-06 18:22:50 +04:00
/* In order to evict this inode, we set it dirty */
2012-11-02 12:11:10 +04:00
mark_inode_dirty ( inode ) ;
2014-11-10 09:15:31 +03:00
if ( IS_DIRSYNC ( dir ) )
f2fs_sync_fs ( sbi - > sb , 1 ) ;
2012-11-02 12:11:10 +04:00
fail :
2013-04-19 20:28:40 +04:00
trace_f2fs_unlink_exit ( inode , err ) ;
2012-11-02 12:11:10 +04:00
return err ;
}
2015-05-02 20:37:52 +03:00
static const char * f2fs_follow_link ( struct dentry * dentry , void * * cookie )
2015-04-15 23:49:55 +03:00
{
2015-05-02 20:37:52 +03:00
const char * link = page_follow_link_light ( dentry , cookie ) ;
2015-05-02 20:32:22 +03:00
if ( ! IS_ERR ( link ) & & ! * link ) {
/* this is broken symlink case */
2015-05-07 18:14:26 +03:00
page_put_link ( NULL , * cookie ) ;
2015-05-02 20:32:22 +03:00
link = ERR_PTR ( - ENOENT ) ;
2015-04-15 23:49:55 +03:00
}
2015-05-02 20:32:22 +03:00
return link ;
2015-04-15 23:49:55 +03:00
}
2012-11-02 12:11:10 +04:00
static int f2fs_symlink ( struct inode * dir , struct dentry * dentry ,
const char * symname )
{
2014-09-03 02:31:18 +04:00
struct f2fs_sb_info * sbi = F2FS_I_SB ( dir ) ;
2012-11-02 12:11:10 +04:00
struct inode * inode ;
2015-04-30 01:10:53 +03:00
size_t len = strlen ( symname ) ;
size_t p_len ;
char * p_str ;
struct f2fs_str disk_link = FSTR_INIT ( NULL , 0 ) ;
struct f2fs_encrypted_symlink_data * sd = NULL ;
f2fs: use rw_sem instead of fs_lock(locks mutex)
The fs_locks is used to block other ops(ex, recovery) when doing checkpoint.
And each other operate routine(besides checkpoint) needs to acquire a fs_lock,
there is a terrible problem here, if these are too many concurrency threads acquiring
fs_lock, so that they will block each other and may lead to some performance problem,
but this is not the phenomenon we want to see.
Though there are some optimization patches introduced to enhance the usage of fs_lock,
but the thorough solution is using a *rw_sem* to replace the fs_lock.
Checkpoint routine takes write_sem, and other ops take read_sem, so that we can block
other ops(ex, recovery) when doing checkpoint, and other ops will not disturb each other,
this can avoid the problem described above completely.
Because of the weakness of rw_sem, the above change may introduce a potential problem
that the checkpoint thread might get starved if other threads are intensively locking
the read semaphore for I/O.(Pointed out by Xu Jin)
In order to avoid this, a wait_list is introduced, the appending read semaphore ops
will be dropped into the wait_list if checkpoint thread is waiting for write semaphore,
and will be waked up when checkpoint thread gives up write semaphore.
Thanks to Kim's previous review and test, and will be very glad to see other guys'
performance tests about this patch.
V2:
-fix the potential starvation problem.
-use more suitable func name suggested by Xu Jin.
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
[Jaegeuk Kim: adjust minor coding standard]
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-09-27 14:08:30 +04:00
int err ;
2012-11-02 12:11:10 +04:00
2015-04-30 01:10:53 +03:00
if ( len > dir - > i_sb - > s_blocksize )
return - ENAMETOOLONG ;
2012-11-02 12:11:10 +04:00
inode = f2fs_new_inode ( dir , S_IFLNK | S_IRWXUGO ) ;
if ( IS_ERR ( inode ) )
return PTR_ERR ( inode ) ;
2015-04-30 01:10:53 +03:00
if ( f2fs_encrypted_inode ( inode ) )
inode - > i_op = & f2fs_encrypted_symlink_inode_operations ;
else
inode - > i_op = & f2fs_symlink_inode_operations ;
2012-11-02 12:11:10 +04:00
inode - > i_mapping - > a_ops = & f2fs_dblock_aops ;
2015-12-22 22:56:08 +03:00
f2fs_balance_fs ( sbi ) ;
f2fs: use rw_sem instead of fs_lock(locks mutex)
The fs_locks is used to block other ops(ex, recovery) when doing checkpoint.
And each other operate routine(besides checkpoint) needs to acquire a fs_lock,
there is a terrible problem here, if these are too many concurrency threads acquiring
fs_lock, so that they will block each other and may lead to some performance problem,
but this is not the phenomenon we want to see.
Though there are some optimization patches introduced to enhance the usage of fs_lock,
but the thorough solution is using a *rw_sem* to replace the fs_lock.
Checkpoint routine takes write_sem, and other ops take read_sem, so that we can block
other ops(ex, recovery) when doing checkpoint, and other ops will not disturb each other,
this can avoid the problem described above completely.
Because of the weakness of rw_sem, the above change may introduce a potential problem
that the checkpoint thread might get starved if other threads are intensively locking
the read semaphore for I/O.(Pointed out by Xu Jin)
In order to avoid this, a wait_list is introduced, the appending read semaphore ops
will be dropped into the wait_list if checkpoint thread is waiting for write semaphore,
and will be waked up when checkpoint thread gives up write semaphore.
Thanks to Kim's previous review and test, and will be very glad to see other guys'
performance tests about this patch.
V2:
-fix the potential starvation problem.
-use more suitable func name suggested by Xu Jin.
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
[Jaegeuk Kim: adjust minor coding standard]
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-09-27 14:08:30 +04:00
f2fs_lock_op ( sbi ) ;
2012-11-02 12:11:10 +04:00
err = f2fs_add_link ( dentry , inode ) ;
if ( err )
goto out ;
2014-09-25 22:55:53 +04:00
f2fs_unlock_op ( sbi ) ;
2012-11-02 12:11:10 +04:00
alloc_nid_done ( sbi , inode - > i_ino ) ;
2015-04-30 01:10:53 +03:00
if ( f2fs_encrypted_inode ( dir ) ) {
struct qstr istr = QSTR_INIT ( symname , len ) ;
2015-05-20 08:26:54 +03:00
err = f2fs_get_encryption_info ( inode ) ;
2015-04-30 01:10:53 +03:00
if ( err )
goto err_out ;
err = f2fs_fname_crypto_alloc_buffer ( inode , len , & disk_link ) ;
if ( err )
goto err_out ;
err = f2fs_fname_usr_to_disk ( inode , & istr , & disk_link ) ;
if ( err < 0 )
goto err_out ;
p_len = encrypted_symlink_data_len ( disk_link . len ) + 1 ;
if ( p_len > dir - > i_sb - > s_blocksize ) {
err = - ENAMETOOLONG ;
goto err_out ;
}
sd = kzalloc ( p_len , GFP_NOFS ) ;
if ( ! sd ) {
err = - ENOMEM ;
goto err_out ;
}
memcpy ( sd - > encrypted_path , disk_link . name , disk_link . len ) ;
sd - > len = cpu_to_le16 ( disk_link . len ) ;
p_str = ( char * ) sd ;
} else {
p_len = len + 1 ;
p_str = ( char * ) symname ;
}
err = page_symlink ( inode , p_str , p_len ) ;
err_out :
2012-11-02 12:11:10 +04:00
d_instantiate ( dentry , inode ) ;
unlock_new_inode ( inode ) ;
2014-11-10 09:15:31 +03:00
2015-04-15 23:37:53 +03:00
/*
* Let ' s flush symlink data in order to avoid broken symlink as much as
* possible . Nevertheless , fsyncing is the best way , but there is no
* way to get a file descriptor in order to flush that .
*
* Note that , it needs to do dir - > fsync to make this recoverable .
* If the symlink path is stored into inline_data , there is no
* performance regression .
*/
2015-10-22 13:23:08 +03:00
if ( ! err ) {
2015-04-30 01:10:53 +03:00
filemap_write_and_wait_range ( inode - > i_mapping , 0 , p_len - 1 ) ;
2015-04-15 23:37:53 +03:00
2015-10-22 13:23:08 +03:00
if ( IS_DIRSYNC ( dir ) )
f2fs_sync_fs ( sbi - > sb , 1 ) ;
} else {
f2fs_unlink ( dir , dentry ) ;
}
2015-04-30 01:10:53 +03:00
kfree ( sd ) ;
f2fs_fname_crypto_free_buffer ( & disk_link ) ;
2012-11-02 12:11:10 +04:00
return err ;
out :
2014-09-25 22:55:53 +04:00
handle_failed_inode ( inode ) ;
2012-11-02 12:11:10 +04:00
return err ;
}
static int f2fs_mkdir ( struct inode * dir , struct dentry * dentry , umode_t mode )
{
2014-09-03 02:31:18 +04:00
struct f2fs_sb_info * sbi = F2FS_I_SB ( dir ) ;
2012-11-02 12:11:10 +04:00
struct inode * inode ;
f2fs: use rw_sem instead of fs_lock(locks mutex)
The fs_locks is used to block other ops(ex, recovery) when doing checkpoint.
And each other operate routine(besides checkpoint) needs to acquire a fs_lock,
there is a terrible problem here, if these are too many concurrency threads acquiring
fs_lock, so that they will block each other and may lead to some performance problem,
but this is not the phenomenon we want to see.
Though there are some optimization patches introduced to enhance the usage of fs_lock,
but the thorough solution is using a *rw_sem* to replace the fs_lock.
Checkpoint routine takes write_sem, and other ops take read_sem, so that we can block
other ops(ex, recovery) when doing checkpoint, and other ops will not disturb each other,
this can avoid the problem described above completely.
Because of the weakness of rw_sem, the above change may introduce a potential problem
that the checkpoint thread might get starved if other threads are intensively locking
the read semaphore for I/O.(Pointed out by Xu Jin)
In order to avoid this, a wait_list is introduced, the appending read semaphore ops
will be dropped into the wait_list if checkpoint thread is waiting for write semaphore,
and will be waked up when checkpoint thread gives up write semaphore.
Thanks to Kim's previous review and test, and will be very glad to see other guys'
performance tests about this patch.
V2:
-fix the potential starvation problem.
-use more suitable func name suggested by Xu Jin.
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
[Jaegeuk Kim: adjust minor coding standard]
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-09-27 14:08:30 +04:00
int err ;
2012-11-02 12:11:10 +04:00
inode = f2fs_new_inode ( dir , S_IFDIR | mode ) ;
if ( IS_ERR ( inode ) )
2012-12-01 05:56:25 +04:00
return PTR_ERR ( inode ) ;
2012-11-02 12:11:10 +04:00
inode - > i_op = & f2fs_dir_inode_operations ;
inode - > i_fop = & f2fs_dir_operations ;
inode - > i_mapping - > a_ops = & f2fs_dblock_aops ;
2015-02-07 12:36:15 +03:00
mapping_set_gfp_mask ( inode - > i_mapping , GFP_F2FS_HIGH_ZERO ) ;
2012-11-02 12:11:10 +04:00
2015-12-22 22:56:08 +03:00
f2fs_balance_fs ( sbi ) ;
2012-11-02 12:11:10 +04:00
set_inode_flag ( F2FS_I ( inode ) , FI_INC_LINK ) ;
f2fs: use rw_sem instead of fs_lock(locks mutex)
The fs_locks is used to block other ops(ex, recovery) when doing checkpoint.
And each other operate routine(besides checkpoint) needs to acquire a fs_lock,
there is a terrible problem here, if these are too many concurrency threads acquiring
fs_lock, so that they will block each other and may lead to some performance problem,
but this is not the phenomenon we want to see.
Though there are some optimization patches introduced to enhance the usage of fs_lock,
but the thorough solution is using a *rw_sem* to replace the fs_lock.
Checkpoint routine takes write_sem, and other ops take read_sem, so that we can block
other ops(ex, recovery) when doing checkpoint, and other ops will not disturb each other,
this can avoid the problem described above completely.
Because of the weakness of rw_sem, the above change may introduce a potential problem
that the checkpoint thread might get starved if other threads are intensively locking
the read semaphore for I/O.(Pointed out by Xu Jin)
In order to avoid this, a wait_list is introduced, the appending read semaphore ops
will be dropped into the wait_list if checkpoint thread is waiting for write semaphore,
and will be waked up when checkpoint thread gives up write semaphore.
Thanks to Kim's previous review and test, and will be very glad to see other guys'
performance tests about this patch.
V2:
-fix the potential starvation problem.
-use more suitable func name suggested by Xu Jin.
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
[Jaegeuk Kim: adjust minor coding standard]
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-09-27 14:08:30 +04:00
f2fs_lock_op ( sbi ) ;
2012-11-02 12:11:10 +04:00
err = f2fs_add_link ( dentry , inode ) ;
if ( err )
goto out_fail ;
2014-09-25 22:55:53 +04:00
f2fs_unlock_op ( sbi ) ;
2012-11-02 12:11:10 +04:00
alloc_nid_done ( sbi , inode - > i_ino ) ;
d_instantiate ( dentry , inode ) ;
unlock_new_inode ( inode ) ;
2014-11-10 09:15:31 +03:00
if ( IS_DIRSYNC ( dir ) )
f2fs_sync_fs ( sbi - > sb , 1 ) ;
2012-11-02 12:11:10 +04:00
return 0 ;
out_fail :
clear_inode_flag ( F2FS_I ( inode ) , FI_INC_LINK ) ;
2014-09-25 22:55:53 +04:00
handle_failed_inode ( inode ) ;
2012-11-02 12:11:10 +04:00
return err ;
}
static int f2fs_rmdir ( struct inode * dir , struct dentry * dentry )
{
2015-03-18 01:25:59 +03:00
struct inode * inode = d_inode ( dentry ) ;
2012-11-02 12:11:10 +04:00
if ( f2fs_empty_dir ( inode ) )
return f2fs_unlink ( dir , dentry ) ;
return - ENOTEMPTY ;
}
static int f2fs_mknod ( struct inode * dir , struct dentry * dentry ,
umode_t mode , dev_t rdev )
{
2014-09-03 02:31:18 +04:00
struct f2fs_sb_info * sbi = F2FS_I_SB ( dir ) ;
2012-11-02 12:11:10 +04:00
struct inode * inode ;
int err = 0 ;
inode = f2fs_new_inode ( dir , mode ) ;
if ( IS_ERR ( inode ) )
return PTR_ERR ( inode ) ;
init_special_inode ( inode , inode - > i_mode , rdev ) ;
inode - > i_op = & f2fs_special_inode_operations ;
2015-12-22 22:56:08 +03:00
f2fs_balance_fs ( sbi ) ;
f2fs: use rw_sem instead of fs_lock(locks mutex)
The fs_locks is used to block other ops(ex, recovery) when doing checkpoint.
And each other operate routine(besides checkpoint) needs to acquire a fs_lock,
there is a terrible problem here, if these are too many concurrency threads acquiring
fs_lock, so that they will block each other and may lead to some performance problem,
but this is not the phenomenon we want to see.
Though there are some optimization patches introduced to enhance the usage of fs_lock,
but the thorough solution is using a *rw_sem* to replace the fs_lock.
Checkpoint routine takes write_sem, and other ops take read_sem, so that we can block
other ops(ex, recovery) when doing checkpoint, and other ops will not disturb each other,
this can avoid the problem described above completely.
Because of the weakness of rw_sem, the above change may introduce a potential problem
that the checkpoint thread might get starved if other threads are intensively locking
the read semaphore for I/O.(Pointed out by Xu Jin)
In order to avoid this, a wait_list is introduced, the appending read semaphore ops
will be dropped into the wait_list if checkpoint thread is waiting for write semaphore,
and will be waked up when checkpoint thread gives up write semaphore.
Thanks to Kim's previous review and test, and will be very glad to see other guys'
performance tests about this patch.
V2:
-fix the potential starvation problem.
-use more suitable func name suggested by Xu Jin.
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
[Jaegeuk Kim: adjust minor coding standard]
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-09-27 14:08:30 +04:00
f2fs_lock_op ( sbi ) ;
2012-11-02 12:11:10 +04:00
err = f2fs_add_link ( dentry , inode ) ;
if ( err )
goto out ;
2014-09-25 22:55:53 +04:00
f2fs_unlock_op ( sbi ) ;
2012-11-02 12:11:10 +04:00
alloc_nid_done ( sbi , inode - > i_ino ) ;
2014-11-10 09:15:31 +03:00
2012-11-02 12:11:10 +04:00
d_instantiate ( dentry , inode ) ;
unlock_new_inode ( inode ) ;
2014-11-10 09:15:31 +03:00
if ( IS_DIRSYNC ( dir ) )
f2fs_sync_fs ( sbi - > sb , 1 ) ;
2012-11-02 12:11:10 +04:00
return 0 ;
out :
2014-09-25 22:55:53 +04:00
handle_failed_inode ( inode ) ;
2012-11-02 12:11:10 +04:00
return err ;
}
f2fs: support RENAME_WHITEOUT
As the description of rename in manual, RENAME_WHITEOUT is a special operation
that only makes sense for overlay/union type filesystem.
When performing rename with RENAME_WHITEOUT, dst will be replace with src, and
meanwhile, a 'whiteout' will be create with name of src.
A "whiteout" is designed to be a char device with 0,0 device number, it has
specially meaning for stackable filesystem. In these filesystems, there are
multiple layers exist, and only top of these can be modified. So a whiteout
in top layer is used to hide a corresponding file in lower layer, as well
removal of whiteout will make the file appear.
Now in overlayfs, when we rename a file which is exist in lower layer, it
will be copied up to upper if it is not on upper layer yet, and then rename
it on upper layer, source file will be whiteouted to hide corresponding file
in lower layer at the same time.
So in upper layer filesystem, implementation of RENAME_WHITEOUT provide a
atomic operation for stackable filesystem to support rename operation.
There are multiple ways to implement RENAME_WHITEOUT in log of this commit:
7dcf5c3e4527 ("xfs: add RENAME_WHITEOUT support") which pointed out by
Dave Chinner.
For now, we just try to follow the way that xfs/ext4 use.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-05-19 12:37:26 +03:00
static int __f2fs_tmpfile ( struct inode * dir , struct dentry * dentry ,
umode_t mode , struct inode * * whiteout )
{
struct f2fs_sb_info * sbi = F2FS_I_SB ( dir ) ;
struct inode * inode ;
int err ;
inode = f2fs_new_inode ( dir , mode ) ;
if ( IS_ERR ( inode ) )
return PTR_ERR ( inode ) ;
if ( whiteout ) {
init_special_inode ( inode , inode - > i_mode , WHITEOUT_DEV ) ;
inode - > i_op = & f2fs_special_inode_operations ;
} else {
inode - > i_op = & f2fs_file_inode_operations ;
inode - > i_fop = & f2fs_file_operations ;
inode - > i_mapping - > a_ops = & f2fs_dblock_aops ;
}
2015-12-22 22:56:08 +03:00
f2fs_balance_fs ( sbi ) ;
f2fs: support RENAME_WHITEOUT
As the description of rename in manual, RENAME_WHITEOUT is a special operation
that only makes sense for overlay/union type filesystem.
When performing rename with RENAME_WHITEOUT, dst will be replace with src, and
meanwhile, a 'whiteout' will be create with name of src.
A "whiteout" is designed to be a char device with 0,0 device number, it has
specially meaning for stackable filesystem. In these filesystems, there are
multiple layers exist, and only top of these can be modified. So a whiteout
in top layer is used to hide a corresponding file in lower layer, as well
removal of whiteout will make the file appear.
Now in overlayfs, when we rename a file which is exist in lower layer, it
will be copied up to upper if it is not on upper layer yet, and then rename
it on upper layer, source file will be whiteouted to hide corresponding file
in lower layer at the same time.
So in upper layer filesystem, implementation of RENAME_WHITEOUT provide a
atomic operation for stackable filesystem to support rename operation.
There are multiple ways to implement RENAME_WHITEOUT in log of this commit:
7dcf5c3e4527 ("xfs: add RENAME_WHITEOUT support") which pointed out by
Dave Chinner.
For now, we just try to follow the way that xfs/ext4 use.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-05-19 12:37:26 +03:00
f2fs_lock_op ( sbi ) ;
err = acquire_orphan_inode ( sbi ) ;
if ( err )
goto out ;
err = f2fs_do_tmpfile ( inode , dir ) ;
if ( err )
goto release_out ;
/*
* add this non - linked tmpfile to orphan list , in this way we could
* remove all unused data of tmpfile after abnormal power - off .
*/
add_orphan_inode ( sbi , inode - > i_ino ) ;
f2fs_unlock_op ( sbi ) ;
alloc_nid_done ( sbi , inode - > i_ino ) ;
if ( whiteout ) {
inode_dec_link_count ( inode ) ;
* whiteout = inode ;
} else {
d_tmpfile ( dentry , inode ) ;
}
unlock_new_inode ( inode ) ;
return 0 ;
release_out :
release_orphan_inode ( sbi ) ;
out :
handle_failed_inode ( inode ) ;
return err ;
}
static int f2fs_tmpfile ( struct inode * dir , struct dentry * dentry , umode_t mode )
{
2015-05-20 02:11:40 +03:00
if ( f2fs_encrypted_inode ( dir ) ) {
int err = f2fs_get_encryption_info ( dir ) ;
if ( err )
return err ;
}
f2fs: support RENAME_WHITEOUT
As the description of rename in manual, RENAME_WHITEOUT is a special operation
that only makes sense for overlay/union type filesystem.
When performing rename with RENAME_WHITEOUT, dst will be replace with src, and
meanwhile, a 'whiteout' will be create with name of src.
A "whiteout" is designed to be a char device with 0,0 device number, it has
specially meaning for stackable filesystem. In these filesystems, there are
multiple layers exist, and only top of these can be modified. So a whiteout
in top layer is used to hide a corresponding file in lower layer, as well
removal of whiteout will make the file appear.
Now in overlayfs, when we rename a file which is exist in lower layer, it
will be copied up to upper if it is not on upper layer yet, and then rename
it on upper layer, source file will be whiteouted to hide corresponding file
in lower layer at the same time.
So in upper layer filesystem, implementation of RENAME_WHITEOUT provide a
atomic operation for stackable filesystem to support rename operation.
There are multiple ways to implement RENAME_WHITEOUT in log of this commit:
7dcf5c3e4527 ("xfs: add RENAME_WHITEOUT support") which pointed out by
Dave Chinner.
For now, we just try to follow the way that xfs/ext4 use.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-05-19 12:37:26 +03:00
return __f2fs_tmpfile ( dir , dentry , mode , NULL ) ;
}
static int f2fs_create_whiteout ( struct inode * dir , struct inode * * whiteout )
{
return __f2fs_tmpfile ( dir , NULL , S_IFCHR | WHITEOUT_MODE , whiteout ) ;
}
2012-11-02 12:11:10 +04:00
static int f2fs_rename ( struct inode * old_dir , struct dentry * old_dentry ,
f2fs: support RENAME_WHITEOUT
As the description of rename in manual, RENAME_WHITEOUT is a special operation
that only makes sense for overlay/union type filesystem.
When performing rename with RENAME_WHITEOUT, dst will be replace with src, and
meanwhile, a 'whiteout' will be create with name of src.
A "whiteout" is designed to be a char device with 0,0 device number, it has
specially meaning for stackable filesystem. In these filesystems, there are
multiple layers exist, and only top of these can be modified. So a whiteout
in top layer is used to hide a corresponding file in lower layer, as well
removal of whiteout will make the file appear.
Now in overlayfs, when we rename a file which is exist in lower layer, it
will be copied up to upper if it is not on upper layer yet, and then rename
it on upper layer, source file will be whiteouted to hide corresponding file
in lower layer at the same time.
So in upper layer filesystem, implementation of RENAME_WHITEOUT provide a
atomic operation for stackable filesystem to support rename operation.
There are multiple ways to implement RENAME_WHITEOUT in log of this commit:
7dcf5c3e4527 ("xfs: add RENAME_WHITEOUT support") which pointed out by
Dave Chinner.
For now, we just try to follow the way that xfs/ext4 use.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-05-19 12:37:26 +03:00
struct inode * new_dir , struct dentry * new_dentry ,
unsigned int flags )
2012-11-02 12:11:10 +04:00
{
2014-09-03 02:31:18 +04:00
struct f2fs_sb_info * sbi = F2FS_I_SB ( old_dir ) ;
2015-03-18 01:25:59 +03:00
struct inode * old_inode = d_inode ( old_dentry ) ;
struct inode * new_inode = d_inode ( new_dentry ) ;
f2fs: support RENAME_WHITEOUT
As the description of rename in manual, RENAME_WHITEOUT is a special operation
that only makes sense for overlay/union type filesystem.
When performing rename with RENAME_WHITEOUT, dst will be replace with src, and
meanwhile, a 'whiteout' will be create with name of src.
A "whiteout" is designed to be a char device with 0,0 device number, it has
specially meaning for stackable filesystem. In these filesystems, there are
multiple layers exist, and only top of these can be modified. So a whiteout
in top layer is used to hide a corresponding file in lower layer, as well
removal of whiteout will make the file appear.
Now in overlayfs, when we rename a file which is exist in lower layer, it
will be copied up to upper if it is not on upper layer yet, and then rename
it on upper layer, source file will be whiteouted to hide corresponding file
in lower layer at the same time.
So in upper layer filesystem, implementation of RENAME_WHITEOUT provide a
atomic operation for stackable filesystem to support rename operation.
There are multiple ways to implement RENAME_WHITEOUT in log of this commit:
7dcf5c3e4527 ("xfs: add RENAME_WHITEOUT support") which pointed out by
Dave Chinner.
For now, we just try to follow the way that xfs/ext4 use.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-05-19 12:37:26 +03:00
struct inode * whiteout = NULL ;
2012-11-02 12:11:10 +04:00
struct page * old_dir_page ;
f2fs: support RENAME_WHITEOUT
As the description of rename in manual, RENAME_WHITEOUT is a special operation
that only makes sense for overlay/union type filesystem.
When performing rename with RENAME_WHITEOUT, dst will be replace with src, and
meanwhile, a 'whiteout' will be create with name of src.
A "whiteout" is designed to be a char device with 0,0 device number, it has
specially meaning for stackable filesystem. In these filesystems, there are
multiple layers exist, and only top of these can be modified. So a whiteout
in top layer is used to hide a corresponding file in lower layer, as well
removal of whiteout will make the file appear.
Now in overlayfs, when we rename a file which is exist in lower layer, it
will be copied up to upper if it is not on upper layer yet, and then rename
it on upper layer, source file will be whiteouted to hide corresponding file
in lower layer at the same time.
So in upper layer filesystem, implementation of RENAME_WHITEOUT provide a
atomic operation for stackable filesystem to support rename operation.
There are multiple ways to implement RENAME_WHITEOUT in log of this commit:
7dcf5c3e4527 ("xfs: add RENAME_WHITEOUT support") which pointed out by
Dave Chinner.
For now, we just try to follow the way that xfs/ext4 use.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-05-19 12:37:26 +03:00
struct page * old_page , * new_page = NULL ;
2012-11-02 12:11:10 +04:00
struct f2fs_dir_entry * old_dir_entry = NULL ;
struct f2fs_dir_entry * old_entry ;
struct f2fs_dir_entry * new_entry ;
f2fs: use rw_sem instead of fs_lock(locks mutex)
The fs_locks is used to block other ops(ex, recovery) when doing checkpoint.
And each other operate routine(besides checkpoint) needs to acquire a fs_lock,
there is a terrible problem here, if these are too many concurrency threads acquiring
fs_lock, so that they will block each other and may lead to some performance problem,
but this is not the phenomenon we want to see.
Though there are some optimization patches introduced to enhance the usage of fs_lock,
but the thorough solution is using a *rw_sem* to replace the fs_lock.
Checkpoint routine takes write_sem, and other ops take read_sem, so that we can block
other ops(ex, recovery) when doing checkpoint, and other ops will not disturb each other,
this can avoid the problem described above completely.
Because of the weakness of rw_sem, the above change may introduce a potential problem
that the checkpoint thread might get starved if other threads are intensively locking
the read semaphore for I/O.(Pointed out by Xu Jin)
In order to avoid this, a wait_list is introduced, the appending read semaphore ops
will be dropped into the wait_list if checkpoint thread is waiting for write semaphore,
and will be waked up when checkpoint thread gives up write semaphore.
Thanks to Kim's previous review and test, and will be very glad to see other guys'
performance tests about this patch.
V2:
-fix the potential starvation problem.
-use more suitable func name suggested by Xu Jin.
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
[Jaegeuk Kim: adjust minor coding standard]
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-09-27 14:08:30 +04:00
int err = - ENOENT ;
2012-11-02 12:11:10 +04:00
2015-04-22 06:39:58 +03:00
if ( ( old_dir ! = new_dir ) & & f2fs_encrypted_inode ( new_dir ) & &
! f2fs_is_child_context_consistent_with_parent ( new_dir ,
old_inode ) ) {
err = - EPERM ;
goto out ;
}
2012-11-02 12:11:10 +04:00
old_entry = f2fs_find_entry ( old_dir , & old_dentry - > d_name , & old_page ) ;
if ( ! old_entry )
goto out ;
if ( S_ISDIR ( old_inode - > i_mode ) ) {
err = - EIO ;
old_dir_entry = f2fs_parent_dir ( old_inode , & old_dir_page ) ;
if ( ! old_dir_entry )
goto out_old ;
}
f2fs: support RENAME_WHITEOUT
As the description of rename in manual, RENAME_WHITEOUT is a special operation
that only makes sense for overlay/union type filesystem.
When performing rename with RENAME_WHITEOUT, dst will be replace with src, and
meanwhile, a 'whiteout' will be create with name of src.
A "whiteout" is designed to be a char device with 0,0 device number, it has
specially meaning for stackable filesystem. In these filesystems, there are
multiple layers exist, and only top of these can be modified. So a whiteout
in top layer is used to hide a corresponding file in lower layer, as well
removal of whiteout will make the file appear.
Now in overlayfs, when we rename a file which is exist in lower layer, it
will be copied up to upper if it is not on upper layer yet, and then rename
it on upper layer, source file will be whiteouted to hide corresponding file
in lower layer at the same time.
So in upper layer filesystem, implementation of RENAME_WHITEOUT provide a
atomic operation for stackable filesystem to support rename operation.
There are multiple ways to implement RENAME_WHITEOUT in log of this commit:
7dcf5c3e4527 ("xfs: add RENAME_WHITEOUT support") which pointed out by
Dave Chinner.
For now, we just try to follow the way that xfs/ext4 use.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-05-19 12:37:26 +03:00
if ( flags & RENAME_WHITEOUT ) {
err = f2fs_create_whiteout ( old_dir , & whiteout ) ;
if ( err )
goto out_dir ;
}
2012-11-02 12:11:10 +04:00
if ( new_inode ) {
err = - ENOTEMPTY ;
if ( old_dir_entry & & ! f2fs_empty_dir ( new_inode ) )
f2fs: support RENAME_WHITEOUT
As the description of rename in manual, RENAME_WHITEOUT is a special operation
that only makes sense for overlay/union type filesystem.
When performing rename with RENAME_WHITEOUT, dst will be replace with src, and
meanwhile, a 'whiteout' will be create with name of src.
A "whiteout" is designed to be a char device with 0,0 device number, it has
specially meaning for stackable filesystem. In these filesystems, there are
multiple layers exist, and only top of these can be modified. So a whiteout
in top layer is used to hide a corresponding file in lower layer, as well
removal of whiteout will make the file appear.
Now in overlayfs, when we rename a file which is exist in lower layer, it
will be copied up to upper if it is not on upper layer yet, and then rename
it on upper layer, source file will be whiteouted to hide corresponding file
in lower layer at the same time.
So in upper layer filesystem, implementation of RENAME_WHITEOUT provide a
atomic operation for stackable filesystem to support rename operation.
There are multiple ways to implement RENAME_WHITEOUT in log of this commit:
7dcf5c3e4527 ("xfs: add RENAME_WHITEOUT support") which pointed out by
Dave Chinner.
For now, we just try to follow the way that xfs/ext4 use.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-05-19 12:37:26 +03:00
goto out_whiteout ;
2012-11-02 12:11:10 +04:00
err = - ENOENT ;
new_entry = f2fs_find_entry ( new_dir , & new_dentry - > d_name ,
& new_page ) ;
if ( ! new_entry )
f2fs: support RENAME_WHITEOUT
As the description of rename in manual, RENAME_WHITEOUT is a special operation
that only makes sense for overlay/union type filesystem.
When performing rename with RENAME_WHITEOUT, dst will be replace with src, and
meanwhile, a 'whiteout' will be create with name of src.
A "whiteout" is designed to be a char device with 0,0 device number, it has
specially meaning for stackable filesystem. In these filesystems, there are
multiple layers exist, and only top of these can be modified. So a whiteout
in top layer is used to hide a corresponding file in lower layer, as well
removal of whiteout will make the file appear.
Now in overlayfs, when we rename a file which is exist in lower layer, it
will be copied up to upper if it is not on upper layer yet, and then rename
it on upper layer, source file will be whiteouted to hide corresponding file
in lower layer at the same time.
So in upper layer filesystem, implementation of RENAME_WHITEOUT provide a
atomic operation for stackable filesystem to support rename operation.
There are multiple ways to implement RENAME_WHITEOUT in log of this commit:
7dcf5c3e4527 ("xfs: add RENAME_WHITEOUT support") which pointed out by
Dave Chinner.
For now, we just try to follow the way that xfs/ext4 use.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-05-19 12:37:26 +03:00
goto out_whiteout ;
2012-11-02 12:11:10 +04:00
2015-12-22 22:56:08 +03:00
f2fs_balance_fs ( sbi ) ;
2014-06-24 10:16:24 +04:00
f2fs_lock_op ( sbi ) ;
2013-07-30 06:36:53 +04:00
err = acquire_orphan_inode ( sbi ) ;
if ( err )
goto put_out_dir ;
2015-04-30 03:02:18 +03:00
if ( update_dent_inode ( old_inode , new_inode ,
& new_dentry - > d_name ) ) {
2013-07-30 06:36:53 +04:00
release_orphan_inode ( sbi ) ;
goto put_out_dir ;
2013-07-18 13:02:31 +04:00
}
2012-11-02 12:11:10 +04:00
f2fs_set_link ( new_dir , new_entry , new_page , old_inode ) ;
new_inode - > i_ctime = CURRENT_TIME ;
2014-03-20 14:10:08 +04:00
down_write ( & F2FS_I ( new_inode ) - > i_sem ) ;
2012-11-02 12:11:10 +04:00
if ( old_dir_entry )
drop_nlink ( new_inode ) ;
drop_nlink ( new_inode ) ;
2014-03-20 14:10:08 +04:00
up_write ( & F2FS_I ( new_inode ) - > i_sem ) ;
2014-01-21 08:32:12 +04:00
mark_inode_dirty ( new_inode ) ;
2013-07-30 06:36:53 +04:00
2012-11-02 12:11:10 +04:00
if ( ! new_inode - > i_nlink )
add_orphan_inode ( sbi , new_inode - > i_ino ) ;
2013-07-30 06:36:53 +04:00
else
release_orphan_inode ( sbi ) ;
2013-08-26 16:25:31 +04:00
update_inode_page ( old_inode ) ;
f2fs: introduce a new global lock scheme
In the previous version, f2fs uses global locks according to the usage types,
such as directory operations, block allocation, block write, and so on.
Reference the following lock types in f2fs.h.
enum lock_type {
RENAME, /* for renaming operations */
DENTRY_OPS, /* for directory operations */
DATA_WRITE, /* for data write */
DATA_NEW, /* for data allocation */
DATA_TRUNC, /* for data truncate */
NODE_NEW, /* for node allocation */
NODE_TRUNC, /* for node truncate */
NODE_WRITE, /* for node write */
NR_LOCK_TYPE,
};
In that case, we lose the performance under the multi-threading environment,
since every types of operations must be conducted one at a time.
In order to address the problem, let's share the locks globally with a mutex
array regardless of any types.
So, let users grab a mutex and perform their jobs in parallel as much as
possbile.
For this, I propose a new global lock scheme as follows.
0. Data structure
- f2fs_sb_info -> mutex_lock[NR_GLOBAL_LOCKS]
- f2fs_sb_info -> node_write
1. mutex_lock_op(sbi)
- try to get an avaiable lock from the array.
- returns the index of the gottern lock variable.
2. mutex_unlock_op(sbi, index of the lock)
- unlock the given index of the lock.
3. mutex_lock_all(sbi)
- grab all the locks in the array before the checkpoint.
4. mutex_unlock_all(sbi)
- release all the locks in the array after checkpoint.
5. block_operations()
- call mutex_lock_all()
- sync_dirty_dir_inodes()
- grab node_write
- sync_node_pages()
Note that,
the pairs of mutex_lock_op()/mutex_unlock_op() and
mutex_lock_all()/mutex_unlock_all() should be used together.
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2012-11-22 11:21:29 +04:00
update_inode_page ( new_inode ) ;
2012-11-02 12:11:10 +04:00
} else {
2015-12-22 22:56:08 +03:00
f2fs_balance_fs ( sbi ) ;
2014-06-24 10:16:24 +04:00
f2fs_lock_op ( sbi ) ;
2012-11-02 12:11:10 +04:00
err = f2fs_add_link ( new_dentry , old_inode ) ;
2014-06-24 10:16:24 +04:00
if ( err ) {
f2fs_unlock_op ( sbi ) ;
f2fs: support RENAME_WHITEOUT
As the description of rename in manual, RENAME_WHITEOUT is a special operation
that only makes sense for overlay/union type filesystem.
When performing rename with RENAME_WHITEOUT, dst will be replace with src, and
meanwhile, a 'whiteout' will be create with name of src.
A "whiteout" is designed to be a char device with 0,0 device number, it has
specially meaning for stackable filesystem. In these filesystems, there are
multiple layers exist, and only top of these can be modified. So a whiteout
in top layer is used to hide a corresponding file in lower layer, as well
removal of whiteout will make the file appear.
Now in overlayfs, when we rename a file which is exist in lower layer, it
will be copied up to upper if it is not on upper layer yet, and then rename
it on upper layer, source file will be whiteouted to hide corresponding file
in lower layer at the same time.
So in upper layer filesystem, implementation of RENAME_WHITEOUT provide a
atomic operation for stackable filesystem to support rename operation.
There are multiple ways to implement RENAME_WHITEOUT in log of this commit:
7dcf5c3e4527 ("xfs: add RENAME_WHITEOUT support") which pointed out by
Dave Chinner.
For now, we just try to follow the way that xfs/ext4 use.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-05-19 12:37:26 +03:00
goto out_whiteout ;
2014-06-24 10:16:24 +04:00
}
2012-11-02 12:11:10 +04:00
if ( old_dir_entry ) {
inc_nlink ( new_dir ) ;
f2fs: introduce a new global lock scheme
In the previous version, f2fs uses global locks according to the usage types,
such as directory operations, block allocation, block write, and so on.
Reference the following lock types in f2fs.h.
enum lock_type {
RENAME, /* for renaming operations */
DENTRY_OPS, /* for directory operations */
DATA_WRITE, /* for data write */
DATA_NEW, /* for data allocation */
DATA_TRUNC, /* for data truncate */
NODE_NEW, /* for node allocation */
NODE_TRUNC, /* for node truncate */
NODE_WRITE, /* for node write */
NR_LOCK_TYPE,
};
In that case, we lose the performance under the multi-threading environment,
since every types of operations must be conducted one at a time.
In order to address the problem, let's share the locks globally with a mutex
array regardless of any types.
So, let users grab a mutex and perform their jobs in parallel as much as
possbile.
For this, I propose a new global lock scheme as follows.
0. Data structure
- f2fs_sb_info -> mutex_lock[NR_GLOBAL_LOCKS]
- f2fs_sb_info -> node_write
1. mutex_lock_op(sbi)
- try to get an avaiable lock from the array.
- returns the index of the gottern lock variable.
2. mutex_unlock_op(sbi, index of the lock)
- unlock the given index of the lock.
3. mutex_lock_all(sbi)
- grab all the locks in the array before the checkpoint.
4. mutex_unlock_all(sbi)
- release all the locks in the array after checkpoint.
5. block_operations()
- call mutex_lock_all()
- sync_dirty_dir_inodes()
- grab node_write
- sync_node_pages()
Note that,
the pairs of mutex_lock_op()/mutex_unlock_op() and
mutex_lock_all()/mutex_unlock_all() should be used together.
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2012-11-22 11:21:29 +04:00
update_inode_page ( new_dir ) ;
2012-11-02 12:11:10 +04:00
}
}
f2fs: do checkpoint for the renamed inode
If an inode is renamed, it should be registered as file_lost_pino to conduct
checkpoint at f2fs_sync_file.
Otherwise, the inode cannot be recovered due to no dent_mark in the following
scenario.
Note that, this scenario is from xfstests/322.
1. create "a"
2. fsync "a"
3. rename "a" to "b"
4. fsync "b"
5. Sudden power-cut
After recovery is done, "b" should be seen.
However, the result shows "a", since the recovery procedure does not enter
recover_dentry due to no dent_mark.
The reason is like below.
- The nid of "a" is checkpointed during #2, f2fs_sync_file.
- The inode page for "b" produced by #3 is written without dent_mark by
sync_node_pages.
So, this patch fixes this bug by assinging file_lost_pino to the "a"'s inode.
If the pino is lost, f2fs_sync_file conducts checkpoint, and then recovers
the latest pino and its dentry information for further recovery.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-06-30 13:09:55 +04:00
down_write ( & F2FS_I ( old_inode ) - > i_sem ) ;
file_lost_pino ( old_inode ) ;
2015-04-30 03:02:18 +03:00
if ( new_inode & & file_enc_name ( new_inode ) )
file_set_enc_name ( old_inode ) ;
f2fs: do checkpoint for the renamed inode
If an inode is renamed, it should be registered as file_lost_pino to conduct
checkpoint at f2fs_sync_file.
Otherwise, the inode cannot be recovered due to no dent_mark in the following
scenario.
Note that, this scenario is from xfstests/322.
1. create "a"
2. fsync "a"
3. rename "a" to "b"
4. fsync "b"
5. Sudden power-cut
After recovery is done, "b" should be seen.
However, the result shows "a", since the recovery procedure does not enter
recover_dentry due to no dent_mark.
The reason is like below.
- The nid of "a" is checkpointed during #2, f2fs_sync_file.
- The inode page for "b" produced by #3 is written without dent_mark by
sync_node_pages.
So, this patch fixes this bug by assinging file_lost_pino to the "a"'s inode.
If the pino is lost, f2fs_sync_file conducts checkpoint, and then recovers
the latest pino and its dentry information for further recovery.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-06-30 13:09:55 +04:00
up_write ( & F2FS_I ( old_inode ) - > i_sem ) ;
2012-11-02 12:11:10 +04:00
old_inode - > i_ctime = CURRENT_TIME ;
mark_inode_dirty ( old_inode ) ;
2014-09-24 14:17:04 +04:00
f2fs_delete_entry ( old_entry , old_page , old_dir , NULL ) ;
2012-11-02 12:11:10 +04:00
f2fs: support RENAME_WHITEOUT
As the description of rename in manual, RENAME_WHITEOUT is a special operation
that only makes sense for overlay/union type filesystem.
When performing rename with RENAME_WHITEOUT, dst will be replace with src, and
meanwhile, a 'whiteout' will be create with name of src.
A "whiteout" is designed to be a char device with 0,0 device number, it has
specially meaning for stackable filesystem. In these filesystems, there are
multiple layers exist, and only top of these can be modified. So a whiteout
in top layer is used to hide a corresponding file in lower layer, as well
removal of whiteout will make the file appear.
Now in overlayfs, when we rename a file which is exist in lower layer, it
will be copied up to upper if it is not on upper layer yet, and then rename
it on upper layer, source file will be whiteouted to hide corresponding file
in lower layer at the same time.
So in upper layer filesystem, implementation of RENAME_WHITEOUT provide a
atomic operation for stackable filesystem to support rename operation.
There are multiple ways to implement RENAME_WHITEOUT in log of this commit:
7dcf5c3e4527 ("xfs: add RENAME_WHITEOUT support") which pointed out by
Dave Chinner.
For now, we just try to follow the way that xfs/ext4 use.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-05-19 12:37:26 +03:00
if ( whiteout ) {
whiteout - > i_state | = I_LINKABLE ;
set_inode_flag ( F2FS_I ( whiteout ) , FI_INC_LINK ) ;
err = f2fs_add_link ( old_dentry , whiteout ) ;
if ( err )
goto put_out_dir ;
whiteout - > i_state & = ~ I_LINKABLE ;
iput ( whiteout ) ;
}
2012-11-02 12:11:10 +04:00
if ( old_dir_entry ) {
f2fs: support RENAME_WHITEOUT
As the description of rename in manual, RENAME_WHITEOUT is a special operation
that only makes sense for overlay/union type filesystem.
When performing rename with RENAME_WHITEOUT, dst will be replace with src, and
meanwhile, a 'whiteout' will be create with name of src.
A "whiteout" is designed to be a char device with 0,0 device number, it has
specially meaning for stackable filesystem. In these filesystems, there are
multiple layers exist, and only top of these can be modified. So a whiteout
in top layer is used to hide a corresponding file in lower layer, as well
removal of whiteout will make the file appear.
Now in overlayfs, when we rename a file which is exist in lower layer, it
will be copied up to upper if it is not on upper layer yet, and then rename
it on upper layer, source file will be whiteouted to hide corresponding file
in lower layer at the same time.
So in upper layer filesystem, implementation of RENAME_WHITEOUT provide a
atomic operation for stackable filesystem to support rename operation.
There are multiple ways to implement RENAME_WHITEOUT in log of this commit:
7dcf5c3e4527 ("xfs: add RENAME_WHITEOUT support") which pointed out by
Dave Chinner.
For now, we just try to follow the way that xfs/ext4 use.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-05-19 12:37:26 +03:00
if ( old_dir ! = new_dir & & ! whiteout ) {
2012-11-02 12:11:10 +04:00
f2fs_set_link ( old_inode , old_dir_entry ,
old_dir_page , new_dir ) ;
2014-01-21 08:32:12 +04:00
update_inode_page ( old_inode ) ;
2012-11-02 12:11:10 +04:00
} else {
2014-11-22 03:36:28 +03:00
f2fs_dentry_kunmap ( old_inode , old_dir_page ) ;
2012-11-02 12:11:10 +04:00
f2fs_put_page ( old_dir_page , 0 ) ;
}
drop_nlink ( old_dir ) ;
2014-01-21 08:32:12 +04:00
mark_inode_dirty ( old_dir ) ;
f2fs: introduce a new global lock scheme
In the previous version, f2fs uses global locks according to the usage types,
such as directory operations, block allocation, block write, and so on.
Reference the following lock types in f2fs.h.
enum lock_type {
RENAME, /* for renaming operations */
DENTRY_OPS, /* for directory operations */
DATA_WRITE, /* for data write */
DATA_NEW, /* for data allocation */
DATA_TRUNC, /* for data truncate */
NODE_NEW, /* for node allocation */
NODE_TRUNC, /* for node truncate */
NODE_WRITE, /* for node write */
NR_LOCK_TYPE,
};
In that case, we lose the performance under the multi-threading environment,
since every types of operations must be conducted one at a time.
In order to address the problem, let's share the locks globally with a mutex
array regardless of any types.
So, let users grab a mutex and perform their jobs in parallel as much as
possbile.
For this, I propose a new global lock scheme as follows.
0. Data structure
- f2fs_sb_info -> mutex_lock[NR_GLOBAL_LOCKS]
- f2fs_sb_info -> node_write
1. mutex_lock_op(sbi)
- try to get an avaiable lock from the array.
- returns the index of the gottern lock variable.
2. mutex_unlock_op(sbi, index of the lock)
- unlock the given index of the lock.
3. mutex_lock_all(sbi)
- grab all the locks in the array before the checkpoint.
4. mutex_unlock_all(sbi)
- release all the locks in the array after checkpoint.
5. block_operations()
- call mutex_lock_all()
- sync_dirty_dir_inodes()
- grab node_write
- sync_node_pages()
Note that,
the pairs of mutex_lock_op()/mutex_unlock_op() and
mutex_lock_all()/mutex_unlock_all() should be used together.
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2012-11-22 11:21:29 +04:00
update_inode_page ( old_dir ) ;
2012-11-02 12:11:10 +04:00
}
f2fs: use rw_sem instead of fs_lock(locks mutex)
The fs_locks is used to block other ops(ex, recovery) when doing checkpoint.
And each other operate routine(besides checkpoint) needs to acquire a fs_lock,
there is a terrible problem here, if these are too many concurrency threads acquiring
fs_lock, so that they will block each other and may lead to some performance problem,
but this is not the phenomenon we want to see.
Though there are some optimization patches introduced to enhance the usage of fs_lock,
but the thorough solution is using a *rw_sem* to replace the fs_lock.
Checkpoint routine takes write_sem, and other ops take read_sem, so that we can block
other ops(ex, recovery) when doing checkpoint, and other ops will not disturb each other,
this can avoid the problem described above completely.
Because of the weakness of rw_sem, the above change may introduce a potential problem
that the checkpoint thread might get starved if other threads are intensively locking
the read semaphore for I/O.(Pointed out by Xu Jin)
In order to avoid this, a wait_list is introduced, the appending read semaphore ops
will be dropped into the wait_list if checkpoint thread is waiting for write semaphore,
and will be waked up when checkpoint thread gives up write semaphore.
Thanks to Kim's previous review and test, and will be very glad to see other guys'
performance tests about this patch.
V2:
-fix the potential starvation problem.
-use more suitable func name suggested by Xu Jin.
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
[Jaegeuk Kim: adjust minor coding standard]
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2013-09-27 14:08:30 +04:00
f2fs_unlock_op ( sbi ) ;
2014-11-10 09:15:31 +03:00
if ( IS_DIRSYNC ( old_dir ) | | IS_DIRSYNC ( new_dir ) )
f2fs_sync_fs ( sbi - > sb , 1 ) ;
2012-11-02 12:11:10 +04:00
return 0 ;
2013-07-30 06:36:53 +04:00
put_out_dir :
2014-06-24 10:16:24 +04:00
f2fs_unlock_op ( sbi ) ;
f2fs: support RENAME_WHITEOUT
As the description of rename in manual, RENAME_WHITEOUT is a special operation
that only makes sense for overlay/union type filesystem.
When performing rename with RENAME_WHITEOUT, dst will be replace with src, and
meanwhile, a 'whiteout' will be create with name of src.
A "whiteout" is designed to be a char device with 0,0 device number, it has
specially meaning for stackable filesystem. In these filesystems, there are
multiple layers exist, and only top of these can be modified. So a whiteout
in top layer is used to hide a corresponding file in lower layer, as well
removal of whiteout will make the file appear.
Now in overlayfs, when we rename a file which is exist in lower layer, it
will be copied up to upper if it is not on upper layer yet, and then rename
it on upper layer, source file will be whiteouted to hide corresponding file
in lower layer at the same time.
So in upper layer filesystem, implementation of RENAME_WHITEOUT provide a
atomic operation for stackable filesystem to support rename operation.
There are multiple ways to implement RENAME_WHITEOUT in log of this commit:
7dcf5c3e4527 ("xfs: add RENAME_WHITEOUT support") which pointed out by
Dave Chinner.
For now, we just try to follow the way that xfs/ext4 use.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-05-19 12:37:26 +03:00
if ( new_page ) {
f2fs_dentry_kunmap ( new_dir , new_page ) ;
f2fs_put_page ( new_page , 0 ) ;
}
out_whiteout :
if ( whiteout )
iput ( whiteout ) ;
2012-11-02 12:11:10 +04:00
out_dir :
if ( old_dir_entry ) {
2014-11-22 03:36:28 +03:00
f2fs_dentry_kunmap ( old_inode , old_dir_page ) ;
2012-11-02 12:11:10 +04:00
f2fs_put_page ( old_dir_page , 0 ) ;
}
out_old :
2014-11-22 03:36:28 +03:00
f2fs_dentry_kunmap ( old_dir , old_page ) ;
2012-11-02 12:11:10 +04:00
f2fs_put_page ( old_page , 0 ) ;
out :
return err ;
}
2014-07-12 15:13:54 +04:00
static int f2fs_cross_rename ( struct inode * old_dir , struct dentry * old_dentry ,
struct inode * new_dir , struct dentry * new_dentry )
{
2014-09-03 02:31:18 +04:00
struct f2fs_sb_info * sbi = F2FS_I_SB ( old_dir ) ;
2015-03-18 01:25:59 +03:00
struct inode * old_inode = d_inode ( old_dentry ) ;
struct inode * new_inode = d_inode ( new_dentry ) ;
2014-07-12 15:13:54 +04:00
struct page * old_dir_page , * new_dir_page ;
struct page * old_page , * new_page ;
struct f2fs_dir_entry * old_dir_entry = NULL , * new_dir_entry = NULL ;
struct f2fs_dir_entry * old_entry , * new_entry ;
int old_nlink = 0 , new_nlink = 0 ;
int err = - ENOENT ;
2015-05-25 13:07:02 +03:00
if ( ( f2fs_encrypted_inode ( old_dir ) | | f2fs_encrypted_inode ( new_dir ) ) & &
( old_dir ! = new_dir ) & &
( ! f2fs_is_child_context_consistent_with_parent ( new_dir ,
old_inode ) | |
! f2fs_is_child_context_consistent_with_parent ( old_dir ,
new_inode ) ) )
return - EPERM ;
2014-07-12 15:13:54 +04:00
old_entry = f2fs_find_entry ( old_dir , & old_dentry - > d_name , & old_page ) ;
if ( ! old_entry )
goto out ;
new_entry = f2fs_find_entry ( new_dir , & new_dentry - > d_name , & new_page ) ;
if ( ! new_entry )
goto out_old ;
/* prepare for updating ".." directory entry info later */
if ( old_dir ! = new_dir ) {
if ( S_ISDIR ( old_inode - > i_mode ) ) {
err = - EIO ;
old_dir_entry = f2fs_parent_dir ( old_inode ,
& old_dir_page ) ;
if ( ! old_dir_entry )
goto out_new ;
}
if ( S_ISDIR ( new_inode - > i_mode ) ) {
err = - EIO ;
new_dir_entry = f2fs_parent_dir ( new_inode ,
& new_dir_page ) ;
if ( ! new_dir_entry )
goto out_old_dir ;
}
}
/*
* If cross rename between file and directory those are not
* in the same directory , we will inc nlink of file ' s parent
* later , so we should check upper boundary of its nlink .
*/
if ( ( ! old_dir_entry | | ! new_dir_entry ) & &
old_dir_entry ! = new_dir_entry ) {
old_nlink = old_dir_entry ? - 1 : 1 ;
new_nlink = - old_nlink ;
err = - EMLINK ;
if ( ( old_nlink > 0 & & old_inode - > i_nlink > = F2FS_LINK_MAX ) | |
( new_nlink > 0 & & new_inode - > i_nlink > = F2FS_LINK_MAX ) )
goto out_new_dir ;
}
2015-12-22 22:56:08 +03:00
f2fs_balance_fs ( sbi ) ;
2014-07-12 15:13:54 +04:00
f2fs_lock_op ( sbi ) ;
2015-04-30 03:02:18 +03:00
err = update_dent_inode ( old_inode , new_inode , & new_dentry - > d_name ) ;
2014-07-12 15:13:54 +04:00
if ( err )
goto out_unlock ;
2015-04-30 03:02:18 +03:00
if ( file_enc_name ( new_inode ) )
file_set_enc_name ( old_inode ) ;
2014-07-12 15:13:54 +04:00
2015-04-30 03:02:18 +03:00
err = update_dent_inode ( new_inode , old_inode , & old_dentry - > d_name ) ;
2014-07-12 15:13:54 +04:00
if ( err )
goto out_undo ;
2015-04-30 03:02:18 +03:00
if ( file_enc_name ( old_inode ) )
file_set_enc_name ( new_inode ) ;
2014-07-12 15:13:54 +04:00
/* update ".." directory entry info of old dentry */
if ( old_dir_entry )
f2fs_set_link ( old_inode , old_dir_entry , old_dir_page , new_dir ) ;
/* update ".." directory entry info of new dentry */
if ( new_dir_entry )
f2fs_set_link ( new_inode , new_dir_entry , new_dir_page , old_dir ) ;
/* update directory entry info of old dir inode */
f2fs_set_link ( old_dir , old_entry , old_page , new_inode ) ;
down_write ( & F2FS_I ( old_inode ) - > i_sem ) ;
file_lost_pino ( old_inode ) ;
up_write ( & F2FS_I ( old_inode ) - > i_sem ) ;
update_inode_page ( old_inode ) ;
old_dir - > i_ctime = CURRENT_TIME ;
if ( old_nlink ) {
down_write ( & F2FS_I ( old_dir ) - > i_sem ) ;
if ( old_nlink < 0 )
drop_nlink ( old_dir ) ;
else
inc_nlink ( old_dir ) ;
up_write ( & F2FS_I ( old_dir ) - > i_sem ) ;
}
mark_inode_dirty ( old_dir ) ;
update_inode_page ( old_dir ) ;
/* update directory entry info of new dir inode */
f2fs_set_link ( new_dir , new_entry , new_page , old_inode ) ;
down_write ( & F2FS_I ( new_inode ) - > i_sem ) ;
file_lost_pino ( new_inode ) ;
up_write ( & F2FS_I ( new_inode ) - > i_sem ) ;
update_inode_page ( new_inode ) ;
new_dir - > i_ctime = CURRENT_TIME ;
if ( new_nlink ) {
down_write ( & F2FS_I ( new_dir ) - > i_sem ) ;
if ( new_nlink < 0 )
drop_nlink ( new_dir ) ;
else
inc_nlink ( new_dir ) ;
up_write ( & F2FS_I ( new_dir ) - > i_sem ) ;
}
mark_inode_dirty ( new_dir ) ;
update_inode_page ( new_dir ) ;
f2fs_unlock_op ( sbi ) ;
2014-11-10 09:15:31 +03:00
if ( IS_DIRSYNC ( old_dir ) | | IS_DIRSYNC ( new_dir ) )
f2fs_sync_fs ( sbi - > sb , 1 ) ;
2014-07-12 15:13:54 +04:00
return 0 ;
out_undo :
2015-04-30 03:02:18 +03:00
/*
* Still we may fail to recover name info of f2fs_inode here
* Drop it , once its name is set as encrypted
*/
update_dent_inode ( old_inode , old_inode , & old_dentry - > d_name ) ;
2014-07-12 15:13:54 +04:00
out_unlock :
f2fs_unlock_op ( sbi ) ;
out_new_dir :
if ( new_dir_entry ) {
2014-11-22 03:36:28 +03:00
f2fs_dentry_kunmap ( new_inode , new_dir_page ) ;
2014-07-12 15:13:54 +04:00
f2fs_put_page ( new_dir_page , 0 ) ;
}
out_old_dir :
if ( old_dir_entry ) {
2014-11-22 03:36:28 +03:00
f2fs_dentry_kunmap ( old_inode , old_dir_page ) ;
2014-07-12 15:13:54 +04:00
f2fs_put_page ( old_dir_page , 0 ) ;
}
out_new :
2014-11-22 03:36:28 +03:00
f2fs_dentry_kunmap ( new_dir , new_page ) ;
2014-07-12 15:13:54 +04:00
f2fs_put_page ( new_page , 0 ) ;
out_old :
2014-11-22 03:36:28 +03:00
f2fs_dentry_kunmap ( old_dir , old_page ) ;
2014-07-12 15:13:54 +04:00
f2fs_put_page ( old_page , 0 ) ;
out :
return err ;
}
static int f2fs_rename2 ( struct inode * old_dir , struct dentry * old_dentry ,
struct inode * new_dir , struct dentry * new_dentry ,
unsigned int flags )
{
f2fs: support RENAME_WHITEOUT
As the description of rename in manual, RENAME_WHITEOUT is a special operation
that only makes sense for overlay/union type filesystem.
When performing rename with RENAME_WHITEOUT, dst will be replace with src, and
meanwhile, a 'whiteout' will be create with name of src.
A "whiteout" is designed to be a char device with 0,0 device number, it has
specially meaning for stackable filesystem. In these filesystems, there are
multiple layers exist, and only top of these can be modified. So a whiteout
in top layer is used to hide a corresponding file in lower layer, as well
removal of whiteout will make the file appear.
Now in overlayfs, when we rename a file which is exist in lower layer, it
will be copied up to upper if it is not on upper layer yet, and then rename
it on upper layer, source file will be whiteouted to hide corresponding file
in lower layer at the same time.
So in upper layer filesystem, implementation of RENAME_WHITEOUT provide a
atomic operation for stackable filesystem to support rename operation.
There are multiple ways to implement RENAME_WHITEOUT in log of this commit:
7dcf5c3e4527 ("xfs: add RENAME_WHITEOUT support") which pointed out by
Dave Chinner.
For now, we just try to follow the way that xfs/ext4 use.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-05-19 12:37:26 +03:00
if ( flags & ~ ( RENAME_NOREPLACE | RENAME_EXCHANGE | RENAME_WHITEOUT ) )
2014-07-12 15:13:54 +04:00
return - EINVAL ;
if ( flags & RENAME_EXCHANGE ) {
return f2fs_cross_rename ( old_dir , old_dentry ,
new_dir , new_dentry ) ;
}
/*
* VFS has already handled the new dentry existence case ,
* here , we just deal with " RENAME_NOREPLACE " as regular rename .
*/
f2fs: support RENAME_WHITEOUT
As the description of rename in manual, RENAME_WHITEOUT is a special operation
that only makes sense for overlay/union type filesystem.
When performing rename with RENAME_WHITEOUT, dst will be replace with src, and
meanwhile, a 'whiteout' will be create with name of src.
A "whiteout" is designed to be a char device with 0,0 device number, it has
specially meaning for stackable filesystem. In these filesystems, there are
multiple layers exist, and only top of these can be modified. So a whiteout
in top layer is used to hide a corresponding file in lower layer, as well
removal of whiteout will make the file appear.
Now in overlayfs, when we rename a file which is exist in lower layer, it
will be copied up to upper if it is not on upper layer yet, and then rename
it on upper layer, source file will be whiteouted to hide corresponding file
in lower layer at the same time.
So in upper layer filesystem, implementation of RENAME_WHITEOUT provide a
atomic operation for stackable filesystem to support rename operation.
There are multiple ways to implement RENAME_WHITEOUT in log of this commit:
7dcf5c3e4527 ("xfs: add RENAME_WHITEOUT support") which pointed out by
Dave Chinner.
For now, we just try to follow the way that xfs/ext4 use.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-05-19 12:37:26 +03:00
return f2fs_rename ( old_dir , old_dentry , new_dir , new_dentry , flags ) ;
2014-07-12 15:13:54 +04:00
}
2015-04-30 01:10:53 +03:00
# ifdef CONFIG_F2FS_FS_ENCRYPTION
2015-06-25 06:38:29 +03:00
static const char * f2fs_encrypted_follow_link ( struct dentry * dentry , void * * cookie )
2014-06-19 12:23:19 +04:00
{
2015-04-30 01:10:53 +03:00
struct page * cpage = NULL ;
char * caddr , * paddr = NULL ;
struct f2fs_str cstr ;
struct f2fs_str pstr = FSTR_INIT ( NULL , 0 ) ;
struct inode * inode = d_inode ( dentry ) ;
struct f2fs_encrypted_symlink_data * sd ;
loff_t size = min_t ( loff_t , i_size_read ( inode ) , PAGE_SIZE - 1 ) ;
u32 max_size = inode - > i_sb - > s_blocksize ;
int res ;
2015-05-20 08:26:54 +03:00
res = f2fs_get_encryption_info ( inode ) ;
2015-04-30 01:10:53 +03:00
if ( res )
return ERR_PTR ( res ) ;
cpage = read_mapping_page ( inode - > i_mapping , 0 , NULL ) ;
if ( IS_ERR ( cpage ) )
2015-06-25 06:38:29 +03:00
return ERR_CAST ( cpage ) ;
2015-04-30 01:10:53 +03:00
caddr = kmap ( cpage ) ;
caddr [ size ] = 0 ;
/* Symlink is encrypted */
sd = ( struct f2fs_encrypted_symlink_data * ) caddr ;
cstr . len = le16_to_cpu ( sd - > len ) ;
2015-09-03 23:38:23 +03:00
cstr . name = kmalloc ( cstr . len , GFP_NOFS ) ;
if ( ! cstr . name ) {
res = - ENOMEM ;
goto errout ;
}
memcpy ( cstr . name , sd - > encrypted_path , cstr . len ) ;
2015-04-30 01:10:53 +03:00
/* this is broken symlink case */
if ( cstr . name [ 0 ] = = 0 & & cstr . len = = 0 ) {
res = - ENOENT ;
goto errout ;
}
2014-06-21 08:37:02 +04:00
2015-04-30 01:10:53 +03:00
if ( ( cstr . len + sizeof ( struct f2fs_encrypted_symlink_data ) - 1 ) >
max_size ) {
/* Symlink data on the disk is corrupted */
res = - EIO ;
goto errout ;
}
res = f2fs_fname_crypto_alloc_buffer ( inode , cstr . len , & pstr ) ;
if ( res )
goto errout ;
res = f2fs_fname_disk_to_usr ( inode , NULL , & cstr , & pstr ) ;
if ( res < 0 )
goto errout ;
2015-09-03 23:38:23 +03:00
kfree ( cstr . name ) ;
2015-04-30 01:10:53 +03:00
paddr = pstr . name ;
/* Null-terminate the name */
paddr [ res ] = ' \0 ' ;
kunmap ( cpage ) ;
page_cache_release ( cpage ) ;
2015-06-25 06:38:29 +03:00
return * cookie = paddr ;
2015-04-30 01:10:53 +03:00
errout :
2015-09-03 23:38:23 +03:00
kfree ( cstr . name ) ;
2015-04-30 01:10:53 +03:00
f2fs_fname_crypto_free_buffer ( & pstr ) ;
kunmap ( cpage ) ;
page_cache_release ( cpage ) ;
return ERR_PTR ( res ) ;
2014-06-19 12:23:19 +04:00
}
2015-04-30 01:10:53 +03:00
const struct inode_operations f2fs_encrypted_symlink_inode_operations = {
. readlink = generic_readlink ,
. follow_link = f2fs_encrypted_follow_link ,
. put_link = kfree_put_link ,
. getattr = f2fs_getattr ,
. setattr = f2fs_setattr ,
. setxattr = generic_setxattr ,
. getxattr = generic_getxattr ,
. listxattr = f2fs_listxattr ,
. removexattr = generic_removexattr ,
} ;
# endif
2012-11-02 12:11:10 +04:00
const struct inode_operations f2fs_dir_inode_operations = {
. create = f2fs_create ,
. lookup = f2fs_lookup ,
. link = f2fs_link ,
. unlink = f2fs_unlink ,
. symlink = f2fs_symlink ,
. mkdir = f2fs_mkdir ,
. rmdir = f2fs_rmdir ,
. mknod = f2fs_mknod ,
2014-07-12 15:13:54 +04:00
. rename2 = f2fs_rename2 ,
2014-06-19 12:23:19 +04:00
. tmpfile = f2fs_tmpfile ,
2013-06-07 11:33:07 +04:00
. getattr = f2fs_getattr ,
2012-11-02 12:11:10 +04:00
. setattr = f2fs_setattr ,
. get_acl = f2fs_get_acl ,
2013-12-20 17:16:45 +04:00
. set_acl = f2fs_set_acl ,
2012-11-02 12:11:10 +04:00
# ifdef CONFIG_F2FS_FS_XATTR
. setxattr = generic_setxattr ,
. getxattr = generic_getxattr ,
. listxattr = f2fs_listxattr ,
. removexattr = generic_removexattr ,
# endif
} ;
const struct inode_operations f2fs_symlink_inode_operations = {
. readlink = generic_readlink ,
2015-04-15 23:49:55 +03:00
. follow_link = f2fs_follow_link ,
2012-11-02 12:11:10 +04:00
. put_link = page_put_link ,
2013-06-07 11:33:07 +04:00
. getattr = f2fs_getattr ,
2012-11-02 12:11:10 +04:00
. setattr = f2fs_setattr ,
# ifdef CONFIG_F2FS_FS_XATTR
. setxattr = generic_setxattr ,
. getxattr = generic_getxattr ,
. listxattr = f2fs_listxattr ,
. removexattr = generic_removexattr ,
# endif
} ;
const struct inode_operations f2fs_special_inode_operations = {
2013-06-07 11:33:07 +04:00
. getattr = f2fs_getattr ,
2012-11-02 12:11:10 +04:00
. setattr = f2fs_setattr ,
. get_acl = f2fs_get_acl ,
2013-12-20 17:16:45 +04:00
. set_acl = f2fs_set_acl ,
2012-11-02 12:11:10 +04:00
# ifdef CONFIG_F2FS_FS_XATTR
. setxattr = generic_setxattr ,
. getxattr = generic_getxattr ,
. listxattr = f2fs_listxattr ,
. removexattr = generic_removexattr ,
# endif
} ;