* [PATCH RESEND 1/2] fs/anon_inode: Introduce a new lib function anon_inode_getfile_private()
@ 2013-07-16 9:56 ` Gu Zheng
0 siblings, 0 replies; 6+ messages in thread
From: Gu Zheng @ 2013-07-16 9:56 UTC (permalink / raw)
To: Andrew Morton, Mel Gorman, Al Viro, Benjamin
Cc: tangchen, KAMEZAWA Hiroyuki, linux-mm, linux-fsdevel,
linux-kernel, Yasuaki Ishimatsu
Introduce a new lib function anon_inode_getfile_private(), it creates a new file
instance by hooking it up to an anonymous inode, and a dentry that describe the
"class" of the file, similar to anon_inode_getfile(), but each file holds a
single inode. Furthermore, anyone who wants to create a private anon file will
benefit from this change.
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>
---
fs/anon_inodes.c | 66 +++++++++++++++++++++++++++++++++++++++++++
include/linux/anon_inodes.h | 3 ++
2 files changed, 69 insertions(+), 0 deletions(-)
diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c
index 47a65df..85c9618 100644
--- a/fs/anon_inodes.c
+++ b/fs/anon_inodes.c
@@ -109,6 +109,72 @@ static struct file_system_type anon_inode_fs_type = {
};
/**
+ * anon_inode_getfile_private - creates a new file instance by hooking it up to an
+ * anonymous inode, and a dentry that describe the "class"
+ * of the file
+ *
+ * @name: [in] name of the "class" of the new file
+ * @fops: [in] file operations for the new file
+ * @priv: [in] private data for the new file (will be file's private_data)
+ * @flags: [in] flags
+ *
+ *
+ * Similar to anon_inode_getfile, but each file holds a single inode.
+ *
+ */
+struct file *anon_inode_getfile_private(const char *name,
+ const struct file_operations *fops,
+ void *priv, int flags)
+{
+ struct qstr this;
+ struct path path;
+ struct file *file;
+ struct inode *inode;
+
+ if (fops->owner && !try_module_get(fops->owner))
+ return ERR_PTR(-ENOENT);
+
+ inode = anon_inode_mkinode(anon_inode_mnt->mnt_sb);
+ if (IS_ERR(inode)) {
+ file = ERR_PTR(-ENOMEM);
+ goto err_module;
+ }
+
+ /*
+ * Link the inode to a directory entry by creating a unique name
+ * using the inode sequence number.
+ */
+ file = ERR_PTR(-ENOMEM);
+ this.name = name;
+ this.len = strlen(name);
+ this.hash = 0;
+ path.dentry = d_alloc_pseudo(anon_inode_mnt->mnt_sb, &this);
+ if (!path.dentry)
+ goto err_module;
+
+ path.mnt = mntget(anon_inode_mnt);
+
+ d_instantiate(path.dentry, inode);
+
+ file = alloc_file(&path, OPEN_FMODE(flags), fops);
+ if (IS_ERR(file))
+ goto err_dput;
+
+ file->f_mapping = inode->i_mapping;
+ file->f_flags = flags & (O_ACCMODE | O_NONBLOCK);
+ file->private_data = priv;
+
+ return file;
+
+err_dput:
+ path_put(&path);
+err_module:
+ module_put(fops->owner);
+ return file;
+}
+EXPORT_SYMBOL_GPL(anon_inode_getfile_private);
+
+/**
* anon_inode_getfile - creates a new file instance by hooking it up to an
* anonymous inode, and a dentry that describe the "class"
* of the file
diff --git a/include/linux/anon_inodes.h b/include/linux/anon_inodes.h
index 8013a45..cf573c2 100644
--- a/include/linux/anon_inodes.h
+++ b/include/linux/anon_inodes.h
@@ -13,6 +13,9 @@ struct file_operations;
struct file *anon_inode_getfile(const char *name,
const struct file_operations *fops,
void *priv, int flags);
+struct file *anon_inode_getfile_private(const char *name,
+ const struct file_operations *fops,
+ void *priv, int flags);
int anon_inode_getfd(const char *name, const struct file_operations *fops,
void *priv, int flags);
--
1.7.7
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH RESEND 1/2] fs/anon_inode: Introduce a new lib function anon_inode_getfile_private()
@ 2013-07-16 9:56 ` Gu Zheng
0 siblings, 0 replies; 6+ messages in thread
From: Gu Zheng @ 2013-07-16 9:56 UTC (permalink / raw)
To: Andrew Morton, Mel Gorman, Al Viro, Benjamin
Cc: tangchen, KAMEZAWA Hiroyuki, linux-mm, linux-fsdevel,
linux-kernel, Yasuaki Ishimatsu
Introduce a new lib function anon_inode_getfile_private(), it creates a new file
instance by hooking it up to an anonymous inode, and a dentry that describe the
"class" of the file, similar to anon_inode_getfile(), but each file holds a
single inode. Furthermore, anyone who wants to create a private anon file will
benefit from this change.
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>
---
fs/anon_inodes.c | 66 +++++++++++++++++++++++++++++++++++++++++++
include/linux/anon_inodes.h | 3 ++
2 files changed, 69 insertions(+), 0 deletions(-)
diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c
index 47a65df..85c9618 100644
--- a/fs/anon_inodes.c
+++ b/fs/anon_inodes.c
@@ -109,6 +109,72 @@ static struct file_system_type anon_inode_fs_type = {
};
/**
+ * anon_inode_getfile_private - creates a new file instance by hooking it up to an
+ * anonymous inode, and a dentry that describe the "class"
+ * of the file
+ *
+ * @name: [in] name of the "class" of the new file
+ * @fops: [in] file operations for the new file
+ * @priv: [in] private data for the new file (will be file's private_data)
+ * @flags: [in] flags
+ *
+ *
+ * Similar to anon_inode_getfile, but each file holds a single inode.
+ *
+ */
+struct file *anon_inode_getfile_private(const char *name,
+ const struct file_operations *fops,
+ void *priv, int flags)
+{
+ struct qstr this;
+ struct path path;
+ struct file *file;
+ struct inode *inode;
+
+ if (fops->owner && !try_module_get(fops->owner))
+ return ERR_PTR(-ENOENT);
+
+ inode = anon_inode_mkinode(anon_inode_mnt->mnt_sb);
+ if (IS_ERR(inode)) {
+ file = ERR_PTR(-ENOMEM);
+ goto err_module;
+ }
+
+ /*
+ * Link the inode to a directory entry by creating a unique name
+ * using the inode sequence number.
+ */
+ file = ERR_PTR(-ENOMEM);
+ this.name = name;
+ this.len = strlen(name);
+ this.hash = 0;
+ path.dentry = d_alloc_pseudo(anon_inode_mnt->mnt_sb, &this);
+ if (!path.dentry)
+ goto err_module;
+
+ path.mnt = mntget(anon_inode_mnt);
+
+ d_instantiate(path.dentry, inode);
+
+ file = alloc_file(&path, OPEN_FMODE(flags), fops);
+ if (IS_ERR(file))
+ goto err_dput;
+
+ file->f_mapping = inode->i_mapping;
+ file->f_flags = flags & (O_ACCMODE | O_NONBLOCK);
+ file->private_data = priv;
+
+ return file;
+
+err_dput:
+ path_put(&path);
+err_module:
+ module_put(fops->owner);
+ return file;
+}
+EXPORT_SYMBOL_GPL(anon_inode_getfile_private);
+
+/**
* anon_inode_getfile - creates a new file instance by hooking it up to an
* anonymous inode, and a dentry that describe the "class"
* of the file
diff --git a/include/linux/anon_inodes.h b/include/linux/anon_inodes.h
index 8013a45..cf573c2 100644
--- a/include/linux/anon_inodes.h
+++ b/include/linux/anon_inodes.h
@@ -13,6 +13,9 @@ struct file_operations;
struct file *anon_inode_getfile(const char *name,
const struct file_operations *fops,
void *priv, int flags);
+struct file *anon_inode_getfile_private(const char *name,
+ const struct file_operations *fops,
+ void *priv, int flags);
int anon_inode_getfd(const char *name, const struct file_operations *fops,
void *priv, int flags);
--
1.7.7
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH RESEND 1/2] fs/anon_inode: Introduce a new lib function anon_inode_getfile_private()
2013-07-16 9:56 ` Gu Zheng
@ 2013-07-16 13:16 ` Benjamin LaHaise
-1 siblings, 0 replies; 6+ messages in thread
From: Benjamin LaHaise @ 2013-07-16 13:16 UTC (permalink / raw)
To: Gu Zheng
Cc: Andrew Morton, Mel Gorman, Al Viro, tangchen, KAMEZAWA Hiroyuki,
linux-mm, linux-fsdevel, linux-kernel, Yasuaki Ishimatsu
On Tue, Jul 16, 2013 at 05:56:12PM +0800, Gu Zheng wrote:
>
> Introduce a new lib function anon_inode_getfile_private(), it creates a new file
> instance by hooking it up to an anonymous inode, and a dentry that describe the
> "class" of the file, similar to anon_inode_getfile(), but each file holds a
> single inode. Furthermore, anyone who wants to create a private anon file will
> benefit from this change.
>
> Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
> Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>
Please don't add my Signed-off-by when I have never even seen or reviewed
a patch -- that is completely unacceptable. Second, I don't think this
patch is suitable for 3.11, as it has not seen much testing outside of one
test program I had written. It's a long standing bug, so it isn't urgent
to get the fix into the tree. That said, it did pass a few tests I ran
last night, so it is probably suitable for the -next tree.
As for patch 1, it looks okay to me, but will need Al Viro's signoff.
-ben
--
"Thought is the essence of where you are now."
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH RESEND 1/2] fs/anon_inode: Introduce a new lib function anon_inode_getfile_private()
@ 2013-07-16 13:16 ` Benjamin LaHaise
0 siblings, 0 replies; 6+ messages in thread
From: Benjamin LaHaise @ 2013-07-16 13:16 UTC (permalink / raw)
To: Gu Zheng
Cc: Andrew Morton, Mel Gorman, Al Viro, tangchen, KAMEZAWA Hiroyuki,
linux-mm, linux-fsdevel, linux-kernel, Yasuaki Ishimatsu
On Tue, Jul 16, 2013 at 05:56:12PM +0800, Gu Zheng wrote:
>
> Introduce a new lib function anon_inode_getfile_private(), it creates a new file
> instance by hooking it up to an anonymous inode, and a dentry that describe the
> "class" of the file, similar to anon_inode_getfile(), but each file holds a
> single inode. Furthermore, anyone who wants to create a private anon file will
> benefit from this change.
>
> Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
> Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>
Please don't add my Signed-off-by when I have never even seen or reviewed
a patch -- that is completely unacceptable. Second, I don't think this
patch is suitable for 3.11, as it has not seen much testing outside of one
test program I had written. It's a long standing bug, so it isn't urgent
to get the fix into the tree. That said, it did pass a few tests I ran
last night, so it is probably suitable for the -next tree.
As for patch 1, it looks okay to me, but will need Al Viro's signoff.
-ben
--
"Thought is the essence of where you are now."
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH RESEND 1/2] fs/anon_inode: Introduce a new lib function anon_inode_getfile_private()
2013-07-16 13:16 ` Benjamin LaHaise
@ 2013-07-17 1:15 ` Gu Zheng
-1 siblings, 0 replies; 6+ messages in thread
From: Gu Zheng @ 2013-07-17 1:15 UTC (permalink / raw)
To: Benjamin LaHaise
Cc: Andrew Morton, Mel Gorman, Al Viro, tangchen, KAMEZAWA Hiroyuki,
linux-mm, linux-fsdevel, linux-kernel, Yasuaki Ishimatsu
Hi Ben,
On 07/16/2013 09:16 PM, Benjamin LaHaise wrote:
> On Tue, Jul 16, 2013 at 05:56:12PM +0800, Gu Zheng wrote:
>>
>> Introduce a new lib function anon_inode_getfile_private(), it creates a new file
>> instance by hooking it up to an anonymous inode, and a dentry that describe the
>> "class" of the file, similar to anon_inode_getfile(), but each file holds a
>> single inode. Furthermore, anyone who wants to create a private anon file will
>> benefit from this change.
>>
>> Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
>> Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>
>
> Please don't add my Signed-off-by when I have never even seen or reviewed
> a patch -- that is completely unacceptable.
Sorry for my reckless action, I'll remember your reminder.:)
> Second, I don't think this
> patch is suitable for 3.11, as it has not seen much testing outside of one
> test program I had written. It's a long standing bug, so it isn't urgent
> to get the fix into the tree. That said, it did pass a few tests I ran
> last night, so it is probably suitable for the -next tree.
Thanks for your test.:)
Regards,
Gu
>
> As for patch 1, it looks okay to me, but will need Al Viro's signoff.
>
> -ben
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH RESEND 1/2] fs/anon_inode: Introduce a new lib function anon_inode_getfile_private()
@ 2013-07-17 1:15 ` Gu Zheng
0 siblings, 0 replies; 6+ messages in thread
From: Gu Zheng @ 2013-07-17 1:15 UTC (permalink / raw)
To: Benjamin LaHaise
Cc: Andrew Morton, Mel Gorman, Al Viro, tangchen, KAMEZAWA Hiroyuki,
linux-mm, linux-fsdevel, linux-kernel, Yasuaki Ishimatsu
Hi Ben,
On 07/16/2013 09:16 PM, Benjamin LaHaise wrote:
> On Tue, Jul 16, 2013 at 05:56:12PM +0800, Gu Zheng wrote:
>>
>> Introduce a new lib function anon_inode_getfile_private(), it creates a new file
>> instance by hooking it up to an anonymous inode, and a dentry that describe the
>> "class" of the file, similar to anon_inode_getfile(), but each file holds a
>> single inode. Furthermore, anyone who wants to create a private anon file will
>> benefit from this change.
>>
>> Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
>> Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>
>
> Please don't add my Signed-off-by when I have never even seen or reviewed
> a patch -- that is completely unacceptable.
Sorry for my reckless action, I'll remember your reminder.:)
> Second, I don't think this
> patch is suitable for 3.11, as it has not seen much testing outside of one
> test program I had written. It's a long standing bug, so it isn't urgent
> to get the fix into the tree. That said, it did pass a few tests I ran
> last night, so it is probably suitable for the -next tree.
Thanks for your test.:)
Regards,
Gu
>
> As for patch 1, it looks okay to me, but will need Al Viro's signoff.
>
> -ben
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-07-17 1:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-16 9:56 [PATCH RESEND 1/2] fs/anon_inode: Introduce a new lib function anon_inode_getfile_private() Gu Zheng
2013-07-16 9:56 ` Gu Zheng
2013-07-16 13:16 ` Benjamin LaHaise
2013-07-16 13:16 ` Benjamin LaHaise
2013-07-17 1:15 ` Gu Zheng
2013-07-17 1:15 ` Gu Zheng
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.