make FS exportable plus some clean-up
Subsystems (2)
v2 cover make FS exportable plus some clean-up
This small patchset makes AFFS work with NFS for standard operations. V2 adds a new patch suggested by Alexander Viro in order to work with cold dcache.
Fabian Frederick (7):
fs/affs: remove reference to affs_parent_ino()
fs/affs: add validation block function
fs/affs: make affs exportable
fs/affs: use octal for permissions
fs/affs: add prefix to some functions
fs/affs/namei.c: forward declarations clean-up
fs/affs: make export work with cold dcache
fs/affs/affs.h | 22 ++++++++----- fs/affs/amigaffs.c | 42 ++++++++++++------------ fs/affs/inode.c | 9 +++--- fs/affs/namei.c | 95 +++++++++++++++++++++++++++++++++++++++++------------- fs/affs/super.c | 3 +- 5 files changed, 114 insertions(+), 57 deletions(-)
Signature · 1 line
2.9.3
PATCH v2 1/7 fs/affs: remove reference to affs_parent_ino()
That function was removed a long time ago.
--- fs/affs/affs.h | 1 - 1 file changed, 1 deletion(-)
fs/affs/affs.h +0 -1
@@ -178,7 +178,6 @@ extern int affs_rename(struct inode *old_dir, struct dentry *old_dentry,/* inode.c */ -extern unsigned long affs_parent_ino (struct inode *dir);extern struct inode *affs_new_inode (struct inode *dir);extern int affs_notify_change (struct dentry *dentry,struct iattr *attr);extern void affs_evict_inode (struct inode *inode);
Signature · 1 line
2.9.3
PATCH v2 2/7 fs/affs: add validation block function
In reply to Fabian Frederickavoid repeating 4 times the same calculation.
--- fs/affs/affs.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
fs/affs/affs.h +10 -4
@@ -212,6 +212,12 @@ extern const struct address_space_operations affs_aops_ofs;extern const struct dentry_operations affs_dentry_operations;extern const struct dentry_operations affs_intl_dentry_operations; +static inline bool affs_validblock (struct super_block *sb,int block) +{ +return (block >=AFFS_SB (sb)->s_reserved && + block <AFFS_SB (sb)->s_partition_size); +} +static inline void affs_set_blocksize (struct super_block *sb,int size) {
@@ -221,7 +227,7 @@ static inline struct buffer_head * affs_bread(struct super_block *sb, int block) {pr_debug ("%s: %d\n" , __func__, block); -if (block >=AFFS_SB (sb)->s_reserved && block <AFFS_SB (sb)->s_partition_size) +if (affs_validblock (sb, block))return sb_bread (sb, block);return NULL ; }
@@ -229,7 +235,7 @@ static inline struct buffer_head * affs_getblk(struct super_block *sb, int block) {pr_debug ("%s: %d\n" , __func__, block); -if (block >=AFFS_SB (sb)->s_reserved && block <AFFS_SB (sb)->s_partition_size) +if (affs_validblock (sb, block))return sb_getblk (sb, block);return NULL ; }
@@ -238,7 +244,7 @@ affs_getzeroblk(struct super_block *sb, int block) {struct buffer_head *bh;pr_debug ("%s: %d\n" , __func__, block); -if (block >=AFFS_SB (sb)->s_reserved && block <AFFS_SB (sb)->s_partition_size) { +if (affs_validblock (sb, block)) { bh =sb_getblk (sb, block);lock_buffer (bh);memset (bh->b_data,0 , sb->s_blocksize);
@@ -253,7 +259,7 @@ affs_getemptyblk(struct super_block *sb, int block) {struct buffer_head *bh;pr_debug ("%s: %d\n" , __func__, block); -if (block >=AFFS_SB (sb)->s_reserved && block <AFFS_SB (sb)->s_partition_size) { +if (affs_validblock (sb, block)) { bh =sb_getblk (sb, block);wait_on_buffer (bh);set_buffer_uptodate (bh);
Signature · 1 line
2.9.3
PATCH v2 3/7 fs/affs: make affs exportable
In reply to Fabian FrederickAdd standard functions making AFFS work with NFS.
Functions based on ext4 implementation.
Tested on loop device.
--- fs/affs/affs.h | 1 + fs/affs/namei.c | 40 ++++++++++++++++++++++++++++++++++++++++ fs/affs/super.c | 1 + 3 files changed, 42 insertions(+)
fs/affs/affs.h +1 -0
@@ -162,6 +162,7 @@ extern void affs_free_bitmap(struct super_block *sb);/* namei.c */ +extern const struct export_operations affs_export_ops;extern int affs_hash_name (struct super_block *sb,const u8 *name,unsigned int len);extern struct dentry *affs_lookup (struct inode *dir,struct dentry *dentry,unsigned int );extern int affs_unlink (struct inode *dir,struct dentry *dentry);
fs/affs/namei.c +40 -0
@@ -9,6 +9,7 @@*/ #include "affs.h" +#include <linux/exportfs.h> typedef int (*toupper_t )(int );
@@ -465,3 +466,42 @@ affs_rename(struct inode *old_dir, struct dentry *old_dentry,affs_brelse (bh);return retval; } + +static struct inode *affs_nfs_get_inode (struct super_block *sb,u64 ino, +u32 generation) +{ +struct inode *inode; + +if (!affs_validblock (sb, ino)) +return ERR_PTR (-ESTALE ); + + inode =affs_iget (sb, ino); +if (IS_ERR (inode)) +return ERR_CAST (inode); + +if (generation && inode->i_generation != generation) { +iput (inode); +return ERR_PTR (-ESTALE ); + } + +return inode; +} + +static struct dentry *affs_fh_to_dentry (struct super_block *sb,struct fid *fid, +int fh_len,int fh_type) +{ +return generic_fh_to_dentry (sb, fid, fh_len, fh_type, + affs_nfs_get_inode); +} + +static struct dentry *affs_fh_to_parent (struct super_block *sb,struct fid *fid, +int fh_len,int fh_type) +{ +return generic_fh_to_parent (sb, fid, fh_len, fh_type, + affs_nfs_get_inode); +} + +const struct export_operations affs_export_ops = { + .fh_to_dentry = affs_fh_to_dentry, + .fh_to_parent = affs_fh_to_parent, +};
fs/affs/super.c +1 -0
@@ -507,6 +507,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)return -ENOMEM ; } + sb->s_export_op = &affs_export_ops;pr_debug ("s_flags=%lX\n" , sb->s_flags);return 0 ; }
Signature · 1 line
2.9.3
PATCH v2 4/7 fs/affs: use octal for permissions
In reply to Fabian FrederickAccording to commit f90774e1fd27
("checkpatch: look for symbolic permissions and suggest octal instead")
--- fs/affs/amigaffs.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)
fs/affs/amigaffs.c +18 -18
@@ -391,23 +391,23 @@ prot_to_mode(u32 prot)umode_t mode =0 ;if (!(prot &FIBF_NOWRITE )) - mode |=S_IWUSR ; + mode |=0200 ;if (!(prot &FIBF_NOREAD )) - mode |=S_IRUSR ; + mode |=0400 ;if (!(prot &FIBF_NOEXECUTE )) - mode |=S_IXUSR ; + mode |=0100 ;if (prot &FIBF_GRP_WRITE ) - mode |=S_IWGRP ; + mode |=0020 ;if (prot &FIBF_GRP_READ ) - mode |=S_IRGRP ; + mode |=0040 ;if (prot &FIBF_GRP_EXECUTE ) - mode |=S_IXGRP ; + mode |=0010 ;if (prot &FIBF_OTR_WRITE ) - mode |=S_IWOTH ; + mode |=0002 ;if (prot &FIBF_OTR_READ ) - mode |=S_IROTH ; + mode |=0004 ;if (prot &FIBF_OTR_EXECUTE ) - mode |=S_IXOTH ; + mode |=0001 ;return mode; }
@@ -418,23 +418,23 @@ mode_to_prot(struct inode *inode)u32 prot =AFFS_I (inode)->i_protect;umode_t mode = inode->i_mode; -if (!(mode &S_IXUSR )) +if (!(mode &0100 )) prot |=FIBF_NOEXECUTE ; -if (!(mode &S_IRUSR )) +if (!(mode &0400 )) prot |=FIBF_NOREAD ; -if (!(mode &S_IWUSR )) +if (!(mode &0200 )) prot |=FIBF_NOWRITE ; -if (mode &S_IXGRP ) +if (mode &0010 ) prot |=FIBF_GRP_EXECUTE ; -if (mode &S_IRGRP ) +if (mode &0040 ) prot |=FIBF_GRP_READ ; -if (mode &S_IWGRP ) +if (mode &0020 ) prot |=FIBF_GRP_WRITE ; -if (mode &S_IXOTH ) +if (mode &0001 ) prot |=FIBF_OTR_EXECUTE ; -if (mode &S_IROTH ) +if (mode &0004 ) prot |=FIBF_OTR_READ ; -if (mode &S_IWOTH ) +if (mode &0002 ) prot |=FIBF_OTR_WRITE ;AFFS_I (inode)->i_protect = prot;
Signature · 1 line
2.9.3
PATCH v2 5/7 fs/affs: add prefix to some functions
In reply to Fabian Fredericksecs_to_datestamp(time64_t secs, struct affs_date *ds); prot_to_mode(u32 prot);mode_to_prot(struct inode *inode);
were declared without affs_ prefix
--- fs/affs/affs.h | 6 +++--- fs/affs/amigaffs.c | 6 +++--- fs/affs/inode.c | 9 +++++---- fs/affs/namei.c | 6 +++--- fs/affs/super.c | 2 +- 5 files changed, 15 insertions(+), 14 deletions(-)
fs/affs/affs.h +3 -3
@@ -138,9 +138,9 @@ extern int affs_remove_hash(struct inode *dir, struct buffer_head *rem_bh);extern int affs_remove_header (struct dentry *dentry);extern u32 affs_checksum_block (struct super_block *sb,struct buffer_head *bh);extern void affs_fix_checksum (struct super_block *sb,struct buffer_head *bh); -extern void secs_to_datestamp (time64_t secs,struct affs_date *ds); -extern umode_t prot_to_mode (u32 prot); -extern void mode_to_prot (struct inode *inode); +extern void affs_secs_to_datestamp (time64_t secs,struct affs_date *ds); +extern umode_t affs_prot_to_mode (u32 prot); +extern void affs_mode_to_prot (struct inode *inode); __printf(3, 4)extern void affs_error (struct super_block *sb,const char *function,const char *fmt, ...);
fs/affs/amigaffs.c +3 -3
@@ -367,7 +367,7 @@ affs_fix_checksum(struct super_block *sb, struct buffer_head *bh) }void -secs_to_datestamp (time64_t secs,struct affs_date *ds) +affs_secs_to_datestamp (time64_t secs,struct affs_date *ds) {u32 days;u32 minute;
@@ -386,7 +386,7 @@ secs_to_datestamp(time64_t secs, struct affs_date *ds) }umode_t -prot_to_mode (u32 prot) +affs_prot_to_mode (u32 prot) {umode_t mode =0 ;
@@ -413,7 +413,7 @@ prot_to_mode(u32 prot) }void -mode_to_prot (struct inode *inode) +affs_mode_to_prot (struct inode *inode) {u32 prot =AFFS_I (inode)->i_protect;umode_t mode = inode->i_mode;
fs/affs/inode.c +5 -4
@@ -69,7 +69,7 @@ struct inode *affs_iget(struct super_block *sb, unsigned long ino)if (affs_test_opt (sbi->s_flags,SF_SETMODE )) inode->i_mode = sbi->s_mode;else - inode->i_mode =prot_to_mode (prot); + inode->i_mode =affs_prot_to_mode (prot); id =be16_to_cpu (tail->uid);if (id ==0 ||affs_test_opt (sbi->s_flags,SF_SETUID ))
@@ -184,11 +184,12 @@ affs_write_inode(struct inode *inode, struct writeback_control *wbc) } tail =AFFS_TAIL (sb, bh);if (tail->stype ==cpu_to_be32 (ST_ROOT )) { -secs_to_datestamp (inode->i_mtime.tv_sec,&AFFS_ROOT_TAIL (sb, bh)->root_change); +affs_secs_to_datestamp (inode->i_mtime.tv_sec, + &AFFS_ROOT_TAIL (sb, bh)->root_change); }else { tail->protect =cpu_to_be32 (AFFS_I (inode)->i_protect); tail->size =cpu_to_be32 (inode->i_size); -secs_to_datestamp (inode->i_mtime.tv_sec,&tail->change); +affs_secs_to_datestamp (inode->i_mtime.tv_sec, &tail->change);if (!(inode->i_ino ==AFFS_SB (sb)->s_root_block)) { uid =i_uid_read (inode); gid =i_gid_read (inode);
@@ -249,7 +250,7 @@ affs_notify_change(struct dentry *dentry, struct iattr *attr)mark_inode_dirty (inode);if (attr->ia_valid &ATTR_MODE ) -mode_to_prot (inode); +affs_mode_to_prot (inode); out:return error; }
fs/affs/namei.c +3 -3
@@ -272,7 +272,7 @@ affs_create(struct inode *dir, struct dentry *dentry, umode_t mode, bool excl)return -ENOSPC ; inode->i_mode = mode; -mode_to_prot (inode); +affs_mode_to_prot (inode);mark_inode_dirty (inode); inode->i_op = &affs_file_inode_operations;
@@ -302,7 +302,7 @@ affs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)return -ENOSPC ; inode->i_mode =S_IFDIR | mode; -mode_to_prot (inode); +affs_mode_to_prot (inode); inode->i_op = &affs_dir_inode_operations; inode->i_fop = &affs_dir_operations;
@@ -348,7 +348,7 @@ affs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)inode_nohighmem (inode); inode->i_data.a_ops = &affs_symlink_aops; inode->i_mode =S_IFLNK |0777 ; -mode_to_prot (inode); +affs_mode_to_prot (inode); error = -EIO ; bh =affs_bread (sb, inode->i_ino);
fs/affs/super.c +1 -1
@@ -32,7 +32,7 @@ affs_commit_super(struct super_block *sb, int wait)struct affs_root_tail *tail =AFFS_ROOT_TAIL (sb, bh);lock_buffer (bh); -secs_to_datestamp (ktime_get_real_seconds (), &tail->disk_change); +affs_secs_to_datestamp (ktime_get_real_seconds (), &tail->disk_change);affs_fix_checksum (sb, bh);unlock_buffer (bh);
Signature · 1 line
2.9.3
PATCH v2 6/7 fs/affs/namei.c: forward declarations clean-up
In reply to Fabian Frederickmove dentry_operations structures and remove
forward declarations
--- fs/affs/namei.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-)
fs/affs/namei.c +10 -20
@@ -13,26 +13,6 @@typedef int (*toupper_t )(int ); -static int affs_toupper (int ch); -static int affs_hash_dentry (const struct dentry *,struct qstr *); -static int affs_compare_dentry (const struct dentry *dentry, -unsigned int len,const char *str,const struct qstr *name); -static int affs_intl_toupper (int ch); -static int affs_intl_hash_dentry (const struct dentry *,struct qstr *); -static int affs_intl_compare_dentry (const struct dentry *dentry, -unsigned int len,const char *str,const struct qstr *name); - -const struct dentry_operations affs_dentry_operations = { - .d_hash = affs_hash_dentry, - .d_compare = affs_compare_dentry, -}; - -const struct dentry_operations affs_intl_dentry_operations = { - .d_hash = affs_intl_hash_dentry, - .d_compare = affs_intl_compare_dentry, -}; - -/* Simple toupper() for DOS\1 */ static int
@@ -505,3 +485,13 @@ const struct export_operations affs_export_ops = { .fh_to_dentry = affs_fh_to_dentry, .fh_to_parent = affs_fh_to_parent, }; + +const struct dentry_operations affs_dentry_operations = { + .d_hash = affs_hash_dentry, + .d_compare = affs_compare_dentry, +}; + +const struct dentry_operations affs_intl_dentry_operations = { + .d_hash = affs_intl_hash_dentry, + .d_compare = affs_intl_compare_dentry, +};
Signature · 1 line
2.9.3
PATCH v2 7/7 fs/affs: make export work with cold dcache
In reply to Fabian FrederickThis adds get_parent function so that nfs client can still work after cache drop (Tested on NFS v4 with echo 3 > /proc/sys/vm/drop_caches)
--- fs/affs/namei.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
fs/affs/namei.c +19 -0
@@ -447,6 +447,24 @@ affs_rename(struct inode *old_dir, struct dentry *old_dentry,return retval; } +static struct dentry *affs_get_parent (struct dentry *child) +{ +struct inode *parent; +struct buffer_head *bh; + + bh =affs_bread (child->d_sb,d_inode (child)->i_ino); +if (IS_ERR (bh)) +return ERR_CAST (bh); + + parent =affs_iget (child->d_sb, +be32_to_cpu (AFFS_TAIL (child->d_sb, bh)->parent)); +brelse (bh); +if (IS_ERR (parent)) +return ERR_CAST (parent); + +return d_obtain_alias (parent); +} +static struct inode *affs_nfs_get_inode (struct super_block *sb,u64 ino,u32 generation) {
@@ -484,6 +502,7 @@ static struct dentry *affs_fh_to_parent(struct super_block *sb, struct fid *fid,const struct export_operations affs_export_ops = { .fh_to_dentry = affs_fh_to_dentry, .fh_to_parent = affs_fh_to_parent, + .get_parent = affs_get_parent, };const struct dentry_operations affs_dentry_operations = {
Signature · 1 line
2.9.3
Quoted 24 lines · On 09 January 2017 at 20:12 Fabian Frederick <[email protected]> wrote:
This small patchset makes AFFS work with NFS for standard operations. V2 adds a new patch suggested by Alexander Viro in order to work with cold dcache.
Fabian Frederick (7):
fs/affs: remove reference toaffs_parent_ino()
fs/affs: add validation block function
fs/affs: make affs exportable
fs/affs: use octal for permissions
fs/affs: add prefix to some functions
fs/affs/namei.c: forward declarations clean-up
fs/affs: make export work with cold dcachefs/affs/affs.h | 22 ++++++++-----
fs/affs/amigaffs.c| 42 ++++++++++++------------ fs/affs/inode.c | 9 +++--- fs/affs/namei.c | 95
+++++++++++++++++++++++++++++++++++++++++-------------
fs/affs/super.c | 3 +-
Quoted 5 lines
5 files changed, 114 insertions(+), 57 deletions(-)--
2.9.3
Hi Andrew,
Do I have to CC someone else to apply these patches ?
Regards,
Fabian