diff mbox

[v3,28/39] ubifs: record quota information about inode in ubifs_new_inode

Message ID 1442307754-13233-29-git-send-email-yangds.fnst@cn.fujitsu.com
State New
Headers show

Commit Message

Yang Dongsheng Sept. 15, 2015, 9:02 a.m. UTC
Initialize quota and alloc a inode quota information in
ubifs_new_inode(). Then quota would be aware of a new
inode is allocated.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
---
 fs/ubifs/dir.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

Comments

Sheng Yong Sept. 15, 2015, 9:35 a.m. UTC | #1
On 9/15/2015 5:02 PM, Dongsheng Yang wrote:
> Initialize quota and alloc a inode quota information in
> ubifs_new_inode(). Then quota would be aware of a new
> inode is allocated.
> 
> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
> ---
>  fs/ubifs/dir.c | 18 ++++++++++++++++--
>  1 file changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
> index 4db0ceb..802c6ad 100644
> --- a/fs/ubifs/dir.c
> +++ b/fs/ubifs/dir.c
> @@ -41,6 +41,7 @@
>   */
>  
>  #include "ubifs.h"
> +#include <linux/quotaops.h>
>  
>  /**
>   * inherit_flags - inherit flags of the parent inode.
> @@ -90,6 +91,7 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir,
>  {
>  	struct inode *inode;
>  	struct ubifs_inode *ui;
> +	int err = 0;
>  
>  	inode = new_inode(c->vfs_sb);
>  	if (!inode)
> @@ -109,6 +111,11 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir,
>  			 ubifs_current_time(inode);
>  	inode->i_mapping->nrpages = 0;
>  
> +	dquot_initialize(inode);
> +        err = dquot_alloc_inode(inode);
> +        if (err)
> +                goto fail_drop;
> +
Hi, Dongsheng

I got a question here, it seems the inode used for xattr may not be counted in?

thanks,
Sheng
>  	switch (mode & S_IFMT) {
>  	case S_IFREG:
>  		inode->i_mapping->a_ops = &ubifs_file_address_operations;
> @@ -148,8 +155,8 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir,
>  			spin_unlock(&c->cnt_lock);
>  			ubifs_err(c, "out of inode numbers");
>  			make_bad_inode(inode);
> -			iput(inode);
> -			return ERR_PTR(-EINVAL);
> +			err = -EINVAL;
> +			goto fail_free;
>  		}
>  		ubifs_warn(c, "running out of inode numbers (current %lu, max %u)",
>  			   (unsigned long)c->highest_inum, INUM_WATERMARK);
> @@ -166,6 +173,13 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir,
>  	ui->creat_sqnum = ++c->max_sqnum;
>  	spin_unlock(&c->cnt_lock);
>  	return inode;
> +
> +fail_free:
> +	dquot_free_inode(inode);
> +fail_drop:
> +	dquot_drop(inode);
> +	iput(inode);
> +	return ERR_PTR(err);
>  }
>  
>  static int dbg_check_name(const struct ubifs_info *c,
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Yang Dongsheng Sept. 16, 2015, 1:46 a.m. UTC | #2
On 09/15/2015 05:35 PM, Sheng Yong wrote:
>
>
> On 9/15/2015 5:02 PM, Dongsheng Yang wrote:
>> Initialize quota and alloc a inode quota information in
>> ubifs_new_inode(). Then quota would be aware of a new
>> inode is allocated.
>>
>> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
>> ---
>>   fs/ubifs/dir.c | 18 ++++++++++++++++--
>>   1 file changed, 16 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
>> index 4db0ceb..802c6ad 100644
>> --- a/fs/ubifs/dir.c
>> +++ b/fs/ubifs/dir.c
>> @@ -41,6 +41,7 @@
>>    */
>>
>>   #include "ubifs.h"
>> +#include <linux/quotaops.h>
>>
>>   /**
>>    * inherit_flags - inherit flags of the parent inode.
>> @@ -90,6 +91,7 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir,
>>   {
>>   	struct inode *inode;
>>   	struct ubifs_inode *ui;
>> +	int err = 0;
>>
>>   	inode = new_inode(c->vfs_sb);
>>   	if (!inode)
>> @@ -109,6 +111,11 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir,
>>   			 ubifs_current_time(inode);
>>   	inode->i_mapping->nrpages = 0;
>>
>> +	dquot_initialize(inode);
>> +        err = dquot_alloc_inode(inode);
>> +        if (err)
>> +                goto fail_drop;
>> +
> Hi, Dongsheng
>
> I got a question here, it seems the inode used for xattr may not be counted in?

Yes, that's intentional. inodes for xattr is not available to user. So I
think we should not count it in quota.

Yang
>
> thanks,
> Sheng
>>   	switch (mode & S_IFMT) {
>>   	case S_IFREG:
>>   		inode->i_mapping->a_ops = &ubifs_file_address_operations;
>> @@ -148,8 +155,8 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir,
>>   			spin_unlock(&c->cnt_lock);
>>   			ubifs_err(c, "out of inode numbers");
>>   			make_bad_inode(inode);
>> -			iput(inode);
>> -			return ERR_PTR(-EINVAL);
>> +			err = -EINVAL;
>> +			goto fail_free;
>>   		}
>>   		ubifs_warn(c, "running out of inode numbers (current %lu, max %u)",
>>   			   (unsigned long)c->highest_inum, INUM_WATERMARK);
>> @@ -166,6 +173,13 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir,
>>   	ui->creat_sqnum = ++c->max_sqnum;
>>   	spin_unlock(&c->cnt_lock);
>>   	return inode;
>> +
>> +fail_free:
>> +	dquot_free_inode(inode);
>> +fail_drop:
>> +	dquot_drop(inode);
>> +	iput(inode);
>> +	return ERR_PTR(err);
>>   }
>>
>>   static int dbg_check_name(const struct ubifs_info *c,
>>
>
> .
>

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 4db0ceb..802c6ad 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -41,6 +41,7 @@ 
  */
 
 #include "ubifs.h"
+#include <linux/quotaops.h>
 
 /**
  * inherit_flags - inherit flags of the parent inode.
@@ -90,6 +91,7 @@  struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir,
 {
 	struct inode *inode;
 	struct ubifs_inode *ui;
+	int err = 0;
 
 	inode = new_inode(c->vfs_sb);
 	if (!inode)
@@ -109,6 +111,11 @@  struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir,
 			 ubifs_current_time(inode);
 	inode->i_mapping->nrpages = 0;
 
+	dquot_initialize(inode);
+        err = dquot_alloc_inode(inode);
+        if (err)
+                goto fail_drop;
+
 	switch (mode & S_IFMT) {
 	case S_IFREG:
 		inode->i_mapping->a_ops = &ubifs_file_address_operations;
@@ -148,8 +155,8 @@  struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir,
 			spin_unlock(&c->cnt_lock);
 			ubifs_err(c, "out of inode numbers");
 			make_bad_inode(inode);
-			iput(inode);
-			return ERR_PTR(-EINVAL);
+			err = -EINVAL;
+			goto fail_free;
 		}
 		ubifs_warn(c, "running out of inode numbers (current %lu, max %u)",
 			   (unsigned long)c->highest_inum, INUM_WATERMARK);
@@ -166,6 +173,13 @@  struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir,
 	ui->creat_sqnum = ++c->max_sqnum;
 	spin_unlock(&c->cnt_lock);
 	return inode;
+
+fail_free:
+	dquot_free_inode(inode);
+fail_drop:
+	dquot_drop(inode);
+	iput(inode);
+	return ERR_PTR(err);
 }
 
 static int dbg_check_name(const struct ubifs_info *c,