linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2 linux-next] fs/affs/inode.c: mark new inode before hashtable insertion
@ 2015-05-05 18:06 Fabian Frederick
  2015-05-05 18:06 ` [PATCH 2/2 linux-next] AFFS: add tmpfile support Fabian Frederick
  2015-05-06  7:04 ` [PATCH 1/2 linux-next] fs/affs/inode.c: mark new inode before hashtable insertion Jan Kara
  0 siblings, 2 replies; 4+ messages in thread
From: Fabian Frederick @ 2015-05-05 18:06 UTC (permalink / raw)
  To: linux-kernel; +Cc: Fabian Frederick, Andrew Morton, Alexander Viro, Jan Kara

AFFS didn't mark new inode to I_NEW state like other FS
using insert_inode_locked() during creation.
This patch also unlocks inode when setup is complete
or operation failed.

Problem appeared when trying to add tmpfile support.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Jan Kara <jack@suse.cz>
Suggested-by: Jan Kara <jack@suse.cz>
Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
 fs/affs/inode.c | 2 ++
 fs/affs/namei.c | 6 ++++++
 2 files changed, 8 insertions(+)

diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index 1734950..859a9cb 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -323,6 +323,8 @@ affs_new_inode(struct inode *dir)
 	AFFS_I(inode)->i_pa_cnt = 0;
 	AFFS_I(inode)->i_extcnt = 1;
 	AFFS_I(inode)->i_ext_last = ~1;
+	if (insert_inode_locked(inode) < 0)
+		goto err_inode;
 
 	insert_inode_hash(inode);
 
diff --git a/fs/affs/namei.c b/fs/affs/namei.c
index 181e05b..b183540 100644
--- a/fs/affs/namei.c
+++ b/fs/affs/namei.c
@@ -281,9 +281,11 @@ affs_create(struct inode *dir, struct dentry *dentry, umode_t mode, bool excl)
 	error = affs_add_entry(dir, inode, dentry, ST_FILE);
 	if (error) {
 		clear_nlink(inode);
+		unlock_new_inode(inode);
 		iput(inode);
 		return error;
 	}
+	unlock_new_inode(inode);
 	return 0;
 }
 
@@ -310,9 +312,11 @@ affs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 	if (error) {
 		clear_nlink(inode);
 		mark_inode_dirty(inode);
+		unlock_new_inode(inode);
 		iput(inode);
 		return error;
 	}
+	unlock_new_inode(inode);
 	return 0;
 }
 
@@ -391,11 +395,13 @@ affs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
 	if (error)
 		goto err;
 
+	unlock_new_inode(inode);
 	return 0;
 
 err:
 	clear_nlink(inode);
 	mark_inode_dirty(inode);
+	unlock_new_inode(inode);
 	iput(inode);
 	return error;
 }
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2 linux-next] AFFS: add tmpfile support
  2015-05-05 18:06 [PATCH 1/2 linux-next] fs/affs/inode.c: mark new inode before hashtable insertion Fabian Frederick
@ 2015-05-05 18:06 ` Fabian Frederick
  2015-05-06  7:34   ` Jan Kara
  2015-05-06  7:04 ` [PATCH 1/2 linux-next] fs/affs/inode.c: mark new inode before hashtable insertion Jan Kara
  1 sibling, 1 reply; 4+ messages in thread
From: Fabian Frederick @ 2015-05-05 18:06 UTC (permalink / raw)
  To: linux-kernel; +Cc: Fabian Frederick, Andrew Morton, Alexander Viro, Jan Kara

Based on the following patch:
commit 60545d0d4610 ("[O_TMPFILE] it's still short a few helpers,
 but infrastructure should be OK now...")

Tested with xfstests generic/004

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
 fs/affs/affs.h  |  1 +
 fs/affs/dir.c   |  1 +
 fs/affs/namei.c | 23 +++++++++++++++++++++++
 3 files changed, 25 insertions(+)

diff --git a/fs/affs/affs.h b/fs/affs/affs.h
index cffe837..c3f60a5 100644
--- a/fs/affs/affs.h
+++ b/fs/affs/affs.h
@@ -180,6 +180,7 @@ extern int	affs_rename(struct inode *old_dir, struct dentry *old_dentry,
 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 int affs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode);
 extern void			 affs_evict_inode(struct inode *inode);
 extern struct inode		*affs_iget(struct super_block *sb,
 					unsigned long ino);
diff --git a/fs/affs/dir.c b/fs/affs/dir.c
index ac4f318..2b0e5ea 100644
--- a/fs/affs/dir.c
+++ b/fs/affs/dir.c
@@ -37,6 +37,7 @@ const struct inode_operations affs_dir_inode_operations = {
 	.rmdir		= affs_rmdir,
 	.rename		= affs_rename,
 	.setattr	= affs_notify_change,
+	.tmpfile	= affs_tmpfile,
 };
 
 static int
diff --git a/fs/affs/namei.c b/fs/affs/namei.c
index b183540..7c3909a 100644
--- a/fs/affs/namei.c
+++ b/fs/affs/namei.c
@@ -466,3 +466,26 @@ done:
 	affs_brelse(bh);
 	return retval;
 }
+
+int affs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
+{
+
+	struct super_block *sb = dir->i_sb;
+	struct affs_sb_info *sbi = AFFS_SB(sb);
+	struct inode *inode;
+
+	inode = affs_new_inode(dir);
+	if (!inode)
+		return -ENOSPC;
+
+	inode->i_mode = mode;
+	mode_to_prot(inode);
+	inode->i_mapping->a_ops = affs_test_opt(sbi->s_flags, SF_OFS) ?
+				  &affs_aops_ofs : &affs_aops;
+	inode->i_op = &affs_file_inode_operations;
+	inode->i_fop = &affs_file_operations;
+	mark_inode_dirty(inode);
+	d_tmpfile(dentry, inode);
+	unlock_new_inode(inode);
+	return 0;
+}
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2 linux-next] fs/affs/inode.c: mark new inode before hashtable insertion
  2015-05-05 18:06 [PATCH 1/2 linux-next] fs/affs/inode.c: mark new inode before hashtable insertion Fabian Frederick
  2015-05-05 18:06 ` [PATCH 2/2 linux-next] AFFS: add tmpfile support Fabian Frederick
@ 2015-05-06  7:04 ` Jan Kara
  1 sibling, 0 replies; 4+ messages in thread
From: Jan Kara @ 2015-05-06  7:04 UTC (permalink / raw)
  To: Fabian Frederick; +Cc: linux-kernel, Andrew Morton, Alexander Viro, Jan Kara

On Tue 05-05-15 20:06:09, Fabian Frederick wrote:
> AFFS didn't mark new inode to I_NEW state like other FS
> using insert_inode_locked() during creation.
> This patch also unlocks inode when setup is complete
> or operation failed.
> 
> Problem appeared when trying to add tmpfile support.
> 
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Alexander Viro <viro@zeniv.linux.org.uk>
> Cc: Jan Kara <jack@suse.cz>
> Suggested-by: Jan Kara <jack@suse.cz>
> Signed-off-by: Fabian Frederick <fabf@skynet.be>
> ---
>  fs/affs/inode.c | 2 ++
>  fs/affs/namei.c | 6 ++++++
>  2 files changed, 8 insertions(+)
> 
> diff --git a/fs/affs/inode.c b/fs/affs/inode.c
> index 1734950..859a9cb 100644
> --- a/fs/affs/inode.c
> +++ b/fs/affs/inode.c
> @@ -323,6 +323,8 @@ affs_new_inode(struct inode *dir)
>  	AFFS_I(inode)->i_pa_cnt = 0;
>  	AFFS_I(inode)->i_extcnt = 1;
>  	AFFS_I(inode)->i_ext_last = ~1;
> +	if (insert_inode_locked(inode) < 0)
> +		goto err_inode;
>  
>  	insert_inode_hash(inode);
  But you need to also remove insert_inode_hash() to avoid double insert.
Otherwise the patch looks good.

								Honza

>  
> diff --git a/fs/affs/namei.c b/fs/affs/namei.c
> index 181e05b..b183540 100644
> --- a/fs/affs/namei.c
> +++ b/fs/affs/namei.c
> @@ -281,9 +281,11 @@ affs_create(struct inode *dir, struct dentry *dentry, umode_t mode, bool excl)
>  	error = affs_add_entry(dir, inode, dentry, ST_FILE);
>  	if (error) {
>  		clear_nlink(inode);
> +		unlock_new_inode(inode);
>  		iput(inode);
>  		return error;
>  	}
> +	unlock_new_inode(inode);
>  	return 0;
>  }
>  
> @@ -310,9 +312,11 @@ affs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
>  	if (error) {
>  		clear_nlink(inode);
>  		mark_inode_dirty(inode);
> +		unlock_new_inode(inode);
>  		iput(inode);
>  		return error;
>  	}
> +	unlock_new_inode(inode);
>  	return 0;
>  }
>  
> @@ -391,11 +395,13 @@ affs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
>  	if (error)
>  		goto err;
>  
> +	unlock_new_inode(inode);
>  	return 0;
>  
>  err:
>  	clear_nlink(inode);
>  	mark_inode_dirty(inode);
> +	unlock_new_inode(inode);
>  	iput(inode);
>  	return error;
>  }
> -- 
> 1.9.1
> 
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2 linux-next] AFFS: add tmpfile support
  2015-05-05 18:06 ` [PATCH 2/2 linux-next] AFFS: add tmpfile support Fabian Frederick
@ 2015-05-06  7:34   ` Jan Kara
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Kara @ 2015-05-06  7:34 UTC (permalink / raw)
  To: Fabian Frederick; +Cc: linux-kernel, Andrew Morton, Alexander Viro, Jan Kara

On Tue 05-05-15 20:06:10, Fabian Frederick wrote:
> Based on the following patch:
> commit 60545d0d4610 ("[O_TMPFILE] it's still short a few helpers,
>  but infrastructure should be OK now...")
> 
> Tested with xfstests generic/004
> 
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Alexander Viro <viro@zeniv.linux.org.uk>
> Cc: Jan Kara <jack@suse.cz>
> Signed-off-by: Fabian Frederick <fabf@skynet.be>
  The patch looks good. You can add:
Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/affs/affs.h  |  1 +
>  fs/affs/dir.c   |  1 +
>  fs/affs/namei.c | 23 +++++++++++++++++++++++
>  3 files changed, 25 insertions(+)
> 
> diff --git a/fs/affs/affs.h b/fs/affs/affs.h
> index cffe837..c3f60a5 100644
> --- a/fs/affs/affs.h
> +++ b/fs/affs/affs.h
> @@ -180,6 +180,7 @@ extern int	affs_rename(struct inode *old_dir, struct dentry *old_dentry,
>  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 int affs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode);
>  extern void			 affs_evict_inode(struct inode *inode);
>  extern struct inode		*affs_iget(struct super_block *sb,
>  					unsigned long ino);
> diff --git a/fs/affs/dir.c b/fs/affs/dir.c
> index ac4f318..2b0e5ea 100644
> --- a/fs/affs/dir.c
> +++ b/fs/affs/dir.c
> @@ -37,6 +37,7 @@ const struct inode_operations affs_dir_inode_operations = {
>  	.rmdir		= affs_rmdir,
>  	.rename		= affs_rename,
>  	.setattr	= affs_notify_change,
> +	.tmpfile	= affs_tmpfile,
>  };
>  
>  static int
> diff --git a/fs/affs/namei.c b/fs/affs/namei.c
> index b183540..7c3909a 100644
> --- a/fs/affs/namei.c
> +++ b/fs/affs/namei.c
> @@ -466,3 +466,26 @@ done:
>  	affs_brelse(bh);
>  	return retval;
>  }
> +
> +int affs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
> +{
> +
> +	struct super_block *sb = dir->i_sb;
> +	struct affs_sb_info *sbi = AFFS_SB(sb);
> +	struct inode *inode;
> +
> +	inode = affs_new_inode(dir);
> +	if (!inode)
> +		return -ENOSPC;
> +
> +	inode->i_mode = mode;
> +	mode_to_prot(inode);
> +	inode->i_mapping->a_ops = affs_test_opt(sbi->s_flags, SF_OFS) ?
> +				  &affs_aops_ofs : &affs_aops;
> +	inode->i_op = &affs_file_inode_operations;
> +	inode->i_fop = &affs_file_operations;
> +	mark_inode_dirty(inode);
> +	d_tmpfile(dentry, inode);
> +	unlock_new_inode(inode);
> +	return 0;
> +}
> -- 
> 1.9.1
> 
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-05-06  7:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-05 18:06 [PATCH 1/2 linux-next] fs/affs/inode.c: mark new inode before hashtable insertion Fabian Frederick
2015-05-05 18:06 ` [PATCH 2/2 linux-next] AFFS: add tmpfile support Fabian Frederick
2015-05-06  7:34   ` Jan Kara
2015-05-06  7:04 ` [PATCH 1/2 linux-next] fs/affs/inode.c: mark new inode before hashtable insertion Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).