Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1554619 > unrolled thread
| Started by | Fabian Frederick <fabf@skynet.be> |
|---|---|
| First post | 2017-01-09 20:20 +0100 |
| Last post | 2017-01-09 20:20 +0100 |
| Articles | 6 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH V2 0/7 linux-next] make FS exportable plus some clean-up Fabian Frederick <fabf@skynet.be> - 2017-01-09 20:20 +0100
[PATCH V2 5/7 linux-next] fs/affs: add prefix to some functions Fabian Frederick <fabf@skynet.be> - 2017-01-09 20:20 +0100
[PATCH V2 4/7 linux-next] fs/affs: use octal for permissions Fabian Frederick <fabf@skynet.be> - 2017-01-09 20:20 +0100
[PATCH V2 2/7 linux-next] fs/affs: add validation block function Fabian Frederick <fabf@skynet.be> - 2017-01-09 20:20 +0100
[PATCH V2 3/7 linux-next] fs/affs: make affs exportable Fabian Frederick <fabf@skynet.be> - 2017-01-09 20:20 +0100
[PATCH V2 1/7 linux-next] fs/affs: remove reference to affs_parent_ino() Fabian Frederick <fabf@skynet.be> - 2017-01-09 20:20 +0100
| From | Fabian Frederick <fabf@skynet.be> |
|---|---|
| Date | 2017-01-09 20:20 +0100 |
| Subject | [PATCH V2 0/7 linux-next] make FS exportable plus some clean-up |
| Message-ID | <sXNE5-89F-3@gated-at.bofh.it> |
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(-) -- 2.9.3
[toc] | [next] | [standalone]
| From | Fabian Frederick <fabf@skynet.be> |
|---|---|
| Date | 2017-01-09 20:20 +0100 |
| Subject | [PATCH V2 5/7 linux-next] fs/affs: add prefix to some functions |
| Message-ID | <sXNE6-89F-11@gated-at.bofh.it> |
| In reply to | #1554619 |
secs_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
Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
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(-)
diff --git a/fs/affs/affs.h b/fs/affs/affs.h
index 1b55428..2f8bab3 100644
--- a/fs/affs/affs.h
+++ b/fs/affs/affs.h
@@ -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, ...);
diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c
index fd7a754..b573c3b 100644
--- a/fs/affs/amigaffs.c
+++ b/fs/affs/amigaffs.c
@@ -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;
diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index fe4e129..a5e6097 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -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;
}
diff --git a/fs/affs/namei.c b/fs/affs/namei.c
index 04c3156f..906ff5b 100644
--- a/fs/affs/namei.c
+++ b/fs/affs/namei.c
@@ -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);
diff --git a/fs/affs/super.c b/fs/affs/super.c
index 98bd952..37532538 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -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);
--
2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Fabian Frederick <fabf@skynet.be> |
|---|---|
| Date | 2017-01-09 20:20 +0100 |
| Subject | [PATCH V2 4/7 linux-next] fs/affs: use octal for permissions |
| Message-ID | <sXNE6-89F-27@gated-at.bofh.it> |
| In reply to | #1554619 |
According to commit f90774e1fd27
("checkpatch: look for symbolic permissions and suggest octal instead")
Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
fs/affs/amigaffs.c | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c
index 0ec65c1..fd7a754 100644
--- a/fs/affs/amigaffs.c
+++ b/fs/affs/amigaffs.c
@@ -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;
--
2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Fabian Frederick <fabf@skynet.be> |
|---|---|
| Date | 2017-01-09 20:20 +0100 |
| Subject | [PATCH V2 2/7 linux-next] fs/affs: add validation block function |
| Message-ID | <sXNE6-89F-29@gated-at.bofh.it> |
| In reply to | #1554619 |
avoid repeating 4 times the same calculation.
Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
fs/affs/affs.h | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/fs/affs/affs.h b/fs/affs/affs.h
index 899256b..efe6839 100644
--- a/fs/affs/affs.h
+++ b/fs/affs/affs.h
@@ -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);
--
2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Fabian Frederick <fabf@skynet.be> |
|---|---|
| Date | 2017-01-09 20:20 +0100 |
| Subject | [PATCH V2 3/7 linux-next] fs/affs: make affs exportable |
| Message-ID | <sXNE6-89F-31@gated-at.bofh.it> |
| In reply to | #1554619 |
Add standard functions making AFFS work with NFS.
Functions based on ext4 implementation.
Tested on loop device.
Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
fs/affs/affs.h | 1 +
fs/affs/namei.c | 40 ++++++++++++++++++++++++++++++++++++++++
fs/affs/super.c | 1 +
3 files changed, 42 insertions(+)
diff --git a/fs/affs/affs.h b/fs/affs/affs.h
index efe6839..1b55428 100644
--- a/fs/affs/affs.h
+++ b/fs/affs/affs.h
@@ -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);
diff --git a/fs/affs/namei.c b/fs/affs/namei.c
index 29186d2..04c3156f 100644
--- a/fs/affs/namei.c
+++ b/fs/affs/namei.c
@@ -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,
+};
diff --git a/fs/affs/super.c b/fs/affs/super.c
index d638486..98bd952 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -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;
}
--
2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Fabian Frederick <fabf@skynet.be> |
|---|---|
| Date | 2017-01-09 20:20 +0100 |
| Subject | [PATCH V2 1/7 linux-next] fs/affs: remove reference to affs_parent_ino() |
| Message-ID | <sXNE6-89F-33@gated-at.bofh.it> |
| In reply to | #1554619 |
That function was removed a long time ago. Signed-off-by: Fabian Frederick <fabf@skynet.be> --- fs/affs/affs.h | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/affs/affs.h b/fs/affs/affs.h index 2f08877..899256b 100644 --- a/fs/affs/affs.h +++ b/fs/affs/affs.h @@ -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); -- 2.9.3
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web