diff mbox

[4/5] ceph: add missing init_acl() for mkdir() and atomic_open()

Message ID 1392096612-11481-4-git-send-email-zheng.z.yan@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yan, Zheng Feb. 11, 2014, 5:30 a.m. UTC
Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
---
 fs/ceph/dir.c  | 9 +++++----
 fs/ceph/file.c | 1 +
 2 files changed, 6 insertions(+), 4 deletions(-)

Comments

Alex Elder Feb. 11, 2014, 5:45 p.m. UTC | #1
On 02/10/2014 11:30 PM, Yan, Zheng wrote:

This looks OK to me but you should get another
opinion, I haven't really given it as thorough a
review as I normally do.

Reviewed-by: Alex Elder <elder@linaro.org>

> Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
> ---
>  fs/ceph/dir.c  | 9 +++++----
>  fs/ceph/file.c | 1 +
>  2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
> index 6da4df8..3bbd0eb 100644
> --- a/fs/ceph/dir.c
> +++ b/fs/ceph/dir.c
> @@ -695,9 +695,8 @@ static int ceph_mknod(struct inode *dir, struct dentry *dentry,
>  	ceph_mdsc_put_request(req);
>  
>  	if (!err)
> -		err = ceph_init_acl(dentry, dentry->d_inode, dir);
> -
> -	if (err)
> +		ceph_init_acl(dentry, dentry->d_inode, dir);
> +	else
>  		d_drop(dentry);
>  	return err;
>  }
> @@ -776,7 +775,9 @@ static int ceph_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
>  		err = ceph_handle_notrace_create(dir, dentry);
>  	ceph_mdsc_put_request(req);
>  out:
> -	if (err < 0)
> +	if (!err)
> +		ceph_init_acl(dentry, dentry->d_inode, dir);
> +	else

Do symlinks have ACLs?  (I don't know, I just notice that
ceph_symlink() doesn't call ceph_init_acl() on the symlink.)

>  		d_drop(dentry);
>  	return err;
>  }
> diff --git a/fs/ceph/file.c b/fs/ceph/file.c
> index dfd2ce3..09c7afe 100644
> --- a/fs/ceph/file.c
> +++ b/fs/ceph/file.c
> @@ -286,6 +286,7 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
>  	} else {
>  		dout("atomic_open finish_open on dn %p\n", dn);
>  		if (req->r_op == CEPH_MDS_OP_CREATE && req->r_reply_info.has_create_ino) {
> +			ceph_init_acl(dentry, dentry->d_inode, dir);
>  			*opened |= FILE_CREATED;

This seems OK but I have to admit I don't know this path
through the code and I don't have time to really dig into
it right now.

>  		}
>  		err = finish_open(file, dentry, ceph_open, opened);
> 

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Guangliang Zhao Feb. 14, 2014, 5:46 a.m. UTC | #2
On Tue, Feb 11, 2014 at 01:30:11PM +0800, Yan Zheng wrote:

This looks good, but there maybe some hiccups, see below.

The symlink also need ceph_init_acl() as Alex mentioned, I have
add it in the patch.

> Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
> ---
>  fs/ceph/dir.c  | 9 +++++----
>  fs/ceph/file.c | 1 +
>  2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
> index 6da4df8..3bbd0eb 100644
> --- a/fs/ceph/dir.c
> +++ b/fs/ceph/dir.c
> @@ -695,9 +695,8 @@ static int ceph_mknod(struct inode *dir, struct dentry *dentry,
>  	ceph_mdsc_put_request(req);
>  
>  	if (!err)
> -		err = ceph_init_acl(dentry, dentry->d_inode, dir);
> -
> -	if (err)
> +		ceph_init_acl(dentry, dentry->d_inode, dir);
> +	else
>  		d_drop(dentry);

ceph_init_acl() may fail, we shoud take care of the return value.

>  	return err;
>  }
> @@ -776,7 +775,9 @@ static int ceph_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
>  		err = ceph_handle_notrace_create(dir, dentry);
>  	ceph_mdsc_put_request(req);
>  out:
> -	if (err < 0)
> +	if (!err)
> +		ceph_init_acl(dentry, dentry->d_inode, dir);
> +	else
>  		d_drop(dentry);
>  	return err;
>  }
> diff --git a/fs/ceph/file.c b/fs/ceph/file.c
> index dfd2ce3..09c7afe 100644
> --- a/fs/ceph/file.c
> +++ b/fs/ceph/file.c
> @@ -286,6 +286,7 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
>  	} else {
>  		dout("atomic_open finish_open on dn %p\n", dn);
>  		if (req->r_op == CEPH_MDS_OP_CREATE && req->r_reply_info.has_create_ino) {
> +			ceph_init_acl(dentry, dentry->d_inode, dir);

Same to above.

>  			*opened |= FILE_CREATED;
>  		}
>  		err = finish_open(file, dentry, ceph_open, opened);
> -- 
> 1.8.5.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Yan, Zheng Feb. 14, 2014, 6:07 a.m. UTC | #3
On 02/14/2014 01:46 PM, Guangliang Zhao wrote:
> On Tue, Feb 11, 2014 at 01:30:11PM +0800, Yan Zheng wrote:
> 
> This looks good, but there maybe some hiccups, see below.
> 
> The symlink also need ceph_init_acl() as Alex mentioned, I have
> add it in the patch.

will update my patch. 

> 
>> Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
>> ---
>>  fs/ceph/dir.c  | 9 +++++----
>>  fs/ceph/file.c | 1 +
>>  2 files changed, 6 insertions(+), 4 deletions(-)
>>
>> diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
>> index 6da4df8..3bbd0eb 100644
>> --- a/fs/ceph/dir.c
>> +++ b/fs/ceph/dir.c
>> @@ -695,9 +695,8 @@ static int ceph_mknod(struct inode *dir, struct dentry *dentry,
>>  	ceph_mdsc_put_request(req);
>>  
>>  	if (!err)
>> -		err = ceph_init_acl(dentry, dentry->d_inode, dir);
>> -
>> -	if (err)
>> +		ceph_init_acl(dentry, dentry->d_inode, dir);
>> +	else
>>  		d_drop(dentry);
> 
> ceph_init_acl() may fail, we shoud take care of the return value.

I remove the error handling intentionally because creating inode and initializing
ACL are not atomic in current implementation. A better approach is initializing the
ACL on the metadata server, but it requires more works.

Regards
Yan, Zheng

> 
>>  	return err;
>>  }
>> @@ -776,7 +775,9 @@ static int ceph_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
>>  		err = ceph_handle_notrace_create(dir, dentry);
>>  	ceph_mdsc_put_request(req);
>>  out:
>> -	if (err < 0)
>> +	if (!err)
>> +		ceph_init_acl(dentry, dentry->d_inode, dir);
>> +	else
>>  		d_drop(dentry);
>>  	return err;
>>  }
>> diff --git a/fs/ceph/file.c b/fs/ceph/file.c
>> index dfd2ce3..09c7afe 100644
>> --- a/fs/ceph/file.c
>> +++ b/fs/ceph/file.c
>> @@ -286,6 +286,7 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
>>  	} else {
>>  		dout("atomic_open finish_open on dn %p\n", dn);
>>  		if (req->r_op == CEPH_MDS_OP_CREATE && req->r_reply_info.has_create_ino) {
>> +			ceph_init_acl(dentry, dentry->d_inode, dir);
> 
> Same to above.
> 
>>  			*opened |= FILE_CREATED;
>>  		}
>>  		err = finish_open(file, dentry, ceph_open, opened);
>> -- 
>> 1.8.5.3
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" 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/ceph/dir.c b/fs/ceph/dir.c
index 6da4df8..3bbd0eb 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -695,9 +695,8 @@  static int ceph_mknod(struct inode *dir, struct dentry *dentry,
 	ceph_mdsc_put_request(req);
 
 	if (!err)
-		err = ceph_init_acl(dentry, dentry->d_inode, dir);
-
-	if (err)
+		ceph_init_acl(dentry, dentry->d_inode, dir);
+	else
 		d_drop(dentry);
 	return err;
 }
@@ -776,7 +775,9 @@  static int ceph_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 		err = ceph_handle_notrace_create(dir, dentry);
 	ceph_mdsc_put_request(req);
 out:
-	if (err < 0)
+	if (!err)
+		ceph_init_acl(dentry, dentry->d_inode, dir);
+	else
 		d_drop(dentry);
 	return err;
 }
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index dfd2ce3..09c7afe 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -286,6 +286,7 @@  int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
 	} else {
 		dout("atomic_open finish_open on dn %p\n", dn);
 		if (req->r_op == CEPH_MDS_OP_CREATE && req->r_reply_info.has_create_ino) {
+			ceph_init_acl(dentry, dentry->d_inode, dir);
 			*opened |= FILE_CREATED;
 		}
 		err = finish_open(file, dentry, ceph_open, opened);