* [PATCH] zonefs: add sanity check for aggregated conventional zones
@ 2022-11-03 10:32 Johannes Thumshirn
2022-11-04 0:26 ` Damien Le Moal
2022-11-07 7:58 ` Dan Carpenter
0 siblings, 2 replies; 6+ messages in thread
From: Johannes Thumshirn @ 2022-11-03 10:32 UTC (permalink / raw)
To: Damien Le Moal; +Cc: linux-fsdevel, Johannes Thumshirn
When initializing a file inode, check if the zone's size if bigger than
the number of device zone sectors. This can only be the case if we mount
the filesystem with the -oaggr_cnv mount option.
Emit an error in case this case happens and fail the mount.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
fs/zonefs/super.c | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
index 860f0b1032c6..605364638720 100644
--- a/fs/zonefs/super.c
+++ b/fs/zonefs/super.c
@@ -1407,6 +1407,14 @@ static int zonefs_init_file_inode(struct inode *inode, struct blk_zone *zone,
zi->i_ztype = type;
zi->i_zsector = zone->start;
zi->i_zone_size = zone->len << SECTOR_SHIFT;
+ if (zi->i_zone_size > bdev_zone_sectors(sb->s_bdev) << SECTOR_SHIFT &&
+ !sbi->s_features & ZONEFS_F_AGGRCNV) {
+ zonefs_err(sb,
+ "zone size %llu doesn't match device's zone sectors %llu\n",
+ zi->i_zone_size,
+ bdev_zone_sectors(sb->s_bdev) << SECTOR_SHIFT);
+ return -EINVAL;
+ }
zi->i_max_size = min_t(loff_t, MAX_LFS_FILESIZE,
zone->capacity << SECTOR_SHIFT);
@@ -1485,7 +1493,7 @@ static struct dentry *zonefs_create_inode(struct dentry *parent,
dput:
dput(dentry);
- return NULL;
+ return ERR_PTR(ret);
}
struct zonefs_zone_data {
@@ -1505,7 +1513,7 @@ static int zonefs_create_zgroup(struct zonefs_zone_data *zd,
struct blk_zone *zone, *next, *end;
const char *zgroup_name;
char *file_name;
- struct dentry *dir;
+ struct dentry *dir, *ret2;
unsigned int n = 0;
int ret;
@@ -1523,8 +1531,11 @@ static int zonefs_create_zgroup(struct zonefs_zone_data *zd,
zgroup_name = "seq";
dir = zonefs_create_inode(sb->s_root, zgroup_name, NULL, type);
- if (!dir) {
- ret = -ENOMEM;
+ if (IS_ERR_OR_NULL(dir)) {
+ if (!dir)
+ ret = -ENOMEM;
+ else
+ ret = PTR_ERR(dir);
goto free;
}
@@ -1570,8 +1581,12 @@ static int zonefs_create_zgroup(struct zonefs_zone_data *zd,
* Use the file number within its group as file name.
*/
snprintf(file_name, ZONEFS_NAME_MAX - 1, "%u", n);
- if (!zonefs_create_inode(dir, file_name, zone, type)) {
- ret = -ENOMEM;
+ ret2 = zonefs_create_inode(dir, file_name, zone, type);
+ if (IS_ERR_OR_NULL(ret2)) {
+ if (!ret2)
+ ret = -ENOMEM;
+ else
+ ret = PTR_ERR(ret2);
goto free;
}
--
2.37.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] zonefs: add sanity check for aggregated conventional zones
2022-11-03 10:32 [PATCH] zonefs: add sanity check for aggregated conventional zones Johannes Thumshirn
@ 2022-11-04 0:26 ` Damien Le Moal
2022-11-04 9:47 ` Johannes Thumshirn
2022-11-07 7:58 ` Dan Carpenter
1 sibling, 1 reply; 6+ messages in thread
From: Damien Le Moal @ 2022-11-04 0:26 UTC (permalink / raw)
To: Johannes Thumshirn; +Cc: linux-fsdevel
On 11/3/22 19:32, Johannes Thumshirn wrote:
> When initializing a file inode, check if the zone's size if bigger than
> the number of device zone sectors. This can only be the case if we mount
> the filesystem with the -oaggr_cnv mount option.
>
> Emit an error in case this case happens and fail the mount.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
> fs/zonefs/super.c | 27 +++++++++++++++++++++------
> 1 file changed, 21 insertions(+), 6 deletions(-)
>
> diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
> index 860f0b1032c6..605364638720 100644
> --- a/fs/zonefs/super.c
> +++ b/fs/zonefs/super.c
> @@ -1407,6 +1407,14 @@ static int zonefs_init_file_inode(struct inode *inode, struct blk_zone *zone,
> zi->i_ztype = type;
> zi->i_zsector = zone->start;
> zi->i_zone_size = zone->len << SECTOR_SHIFT;
> + if (zi->i_zone_size > bdev_zone_sectors(sb->s_bdev) << SECTOR_SHIFT &&
> + !sbi->s_features & ZONEFS_F_AGGRCNV) {
> + zonefs_err(sb,
> + "zone size %llu doesn't match device's zone sectors %llu\n",
> + zi->i_zone_size,
> + bdev_zone_sectors(sb->s_bdev) << SECTOR_SHIFT);
> + return -EINVAL;
> + }
>
> zi->i_max_size = min_t(loff_t, MAX_LFS_FILESIZE,
> zone->capacity << SECTOR_SHIFT);
> @@ -1485,7 +1493,7 @@ static struct dentry *zonefs_create_inode(struct dentry *parent,
> dput:
> dput(dentry);
>
> - return NULL;
> + return ERR_PTR(ret);
> }
>
> struct zonefs_zone_data {
> @@ -1505,7 +1513,7 @@ static int zonefs_create_zgroup(struct zonefs_zone_data *zd,
> struct blk_zone *zone, *next, *end;
> const char *zgroup_name;
> char *file_name;
> - struct dentry *dir;
> + struct dentry *dir, *ret2;
> unsigned int n = 0;
> int ret;
>
> @@ -1523,8 +1531,11 @@ static int zonefs_create_zgroup(struct zonefs_zone_data *zd,
> zgroup_name = "seq";
>
> dir = zonefs_create_inode(sb->s_root, zgroup_name, NULL, type);
> - if (!dir) {
> - ret = -ENOMEM;
> + if (IS_ERR_OR_NULL(dir)) {
> + if (!dir)
> + ret = -ENOMEM;
It would be cleaner to return ERR_PTR(-ENOMEM) instead of NULL in
zonefs_create_inode(). This way, this can simply be:
if (IS_ERR(dir)) {
ret = PTR_ERR(dir);
goto free;
}
And the hunk below would be similar too.
> + else
> + ret = PTR_ERR(dir);
> goto free;
> }
>
> @@ -1570,8 +1581,12 @@ static int zonefs_create_zgroup(struct zonefs_zone_data *zd,
> * Use the file number within its group as file name.
> */
> snprintf(file_name, ZONEFS_NAME_MAX - 1, "%u", n);
> - if (!zonefs_create_inode(dir, file_name, zone, type)) {
> - ret = -ENOMEM;
> + ret2 = zonefs_create_inode(dir, file_name, zone, type);
> + if (IS_ERR_OR_NULL(ret2)) {
> + if (!ret2)
> + ret = -ENOMEM;
> + else
> + ret = PTR_ERR(ret2);
> goto free;
> }
>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] zonefs: add sanity check for aggregated conventional zones
2022-11-04 0:26 ` Damien Le Moal
@ 2022-11-04 9:47 ` Johannes Thumshirn
2022-11-04 12:06 ` Damien Le Moal
0 siblings, 1 reply; 6+ messages in thread
From: Johannes Thumshirn @ 2022-11-04 9:47 UTC (permalink / raw)
To: Damien Le Moal; +Cc: linux-fsdevel@vger.kernel.org
On 04.11.22 01:26, Damien Le Moal wrote:
> On 11/3/22 19:32, Johannes Thumshirn wrote:
>> When initializing a file inode, check if the zone's size if bigger than
>> the number of device zone sectors. This can only be the case if we mount
>> the filesystem with the -oaggr_cnv mount option.
>>
>> Emit an error in case this case happens and fail the mount.
>>
>> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
>> ---
>> fs/zonefs/super.c | 27 +++++++++++++++++++++------
>> 1 file changed, 21 insertions(+), 6 deletions(-)
>>
>> diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
>> index 860f0b1032c6..605364638720 100644
>> --- a/fs/zonefs/super.c
>> +++ b/fs/zonefs/super.c
>> @@ -1407,6 +1407,14 @@ static int zonefs_init_file_inode(struct inode *inode, struct blk_zone *zone,
>> zi->i_ztype = type;
>> zi->i_zsector = zone->start;
>> zi->i_zone_size = zone->len << SECTOR_SHIFT;
>> + if (zi->i_zone_size > bdev_zone_sectors(sb->s_bdev) << SECTOR_SHIFT &&
>> + !sbi->s_features & ZONEFS_F_AGGRCNV) {
>> + zonefs_err(sb,
>> + "zone size %llu doesn't match device's zone sectors %llu\n",
>> + zi->i_zone_size,
>> + bdev_zone_sectors(sb->s_bdev) << SECTOR_SHIFT);
>> + return -EINVAL;
>> + }
>>
>> zi->i_max_size = min_t(loff_t, MAX_LFS_FILESIZE,
>> zone->capacity << SECTOR_SHIFT);
>> @@ -1485,7 +1493,7 @@ static struct dentry *zonefs_create_inode(struct dentry *parent,
>> dput:
>> dput(dentry);
>>
>> - return NULL;
>> + return ERR_PTR(ret);
>> }
>>
>> struct zonefs_zone_data {
>> @@ -1505,7 +1513,7 @@ static int zonefs_create_zgroup(struct zonefs_zone_data *zd,
>> struct blk_zone *zone, *next, *end;
>> const char *zgroup_name;
>> char *file_name;
>> - struct dentry *dir;
>> + struct dentry *dir, *ret2;
>> unsigned int n = 0;
>> int ret;
>>
>> @@ -1523,8 +1531,11 @@ static int zonefs_create_zgroup(struct zonefs_zone_data *zd,
>> zgroup_name = "seq";
>>
>> dir = zonefs_create_inode(sb->s_root, zgroup_name, NULL, type);
>> - if (!dir) {
>> - ret = -ENOMEM;
>> + if (IS_ERR_OR_NULL(dir)) {
>> + if (!dir)
>> + ret = -ENOMEM;
>
> It would be cleaner to return ERR_PTR(-ENOMEM) instead of NULL in
> zonefs_create_inode(). This way, this can simply be:
> if (IS_ERR(dir)) {
> ret = PTR_ERR(dir);
> goto free;
> }
>
> And the hunk below would be similar too.
>
Agreed, I'll update the patch. Or do you want to do it when squashing it
into your "zonefs: fix zone report size in __zonefs_io_error()" patch?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] zonefs: add sanity check for aggregated conventional zones
2022-11-04 9:47 ` Johannes Thumshirn
@ 2022-11-04 12:06 ` Damien Le Moal
2022-11-04 12:36 ` Johannes Thumshirn
0 siblings, 1 reply; 6+ messages in thread
From: Damien Le Moal @ 2022-11-04 12:06 UTC (permalink / raw)
To: Johannes Thumshirn; +Cc: linux-fsdevel@vger.kernel.org
On 11/4/22 18:47, Johannes Thumshirn wrote:
> On 04.11.22 01:26, Damien Le Moal wrote:
>> On 11/3/22 19:32, Johannes Thumshirn wrote:
>>> When initializing a file inode, check if the zone's size if bigger than
>>> the number of device zone sectors. This can only be the case if we mount
>>> the filesystem with the -oaggr_cnv mount option.
>>>
>>> Emit an error in case this case happens and fail the mount.
>>>
>>> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
>>> ---
>>> fs/zonefs/super.c | 27 +++++++++++++++++++++------
>>> 1 file changed, 21 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
>>> index 860f0b1032c6..605364638720 100644
>>> --- a/fs/zonefs/super.c
>>> +++ b/fs/zonefs/super.c
>>> @@ -1407,6 +1407,14 @@ static int zonefs_init_file_inode(struct inode *inode, struct blk_zone *zone,
>>> zi->i_ztype = type;
>>> zi->i_zsector = zone->start;
>>> zi->i_zone_size = zone->len << SECTOR_SHIFT;
>>> + if (zi->i_zone_size > bdev_zone_sectors(sb->s_bdev) << SECTOR_SHIFT &&
>>> + !sbi->s_features & ZONEFS_F_AGGRCNV) {
>>> + zonefs_err(sb,
>>> + "zone size %llu doesn't match device's zone sectors %llu\n",
>>> + zi->i_zone_size,
>>> + bdev_zone_sectors(sb->s_bdev) << SECTOR_SHIFT);
>>> + return -EINVAL;
>>> + }
>>>
>>> zi->i_max_size = min_t(loff_t, MAX_LFS_FILESIZE,
>>> zone->capacity << SECTOR_SHIFT);
>>> @@ -1485,7 +1493,7 @@ static struct dentry *zonefs_create_inode(struct dentry *parent,
>>> dput:
>>> dput(dentry);
>>>
>>> - return NULL;
>>> + return ERR_PTR(ret);
>>> }
>>>
>>> struct zonefs_zone_data {
>>> @@ -1505,7 +1513,7 @@ static int zonefs_create_zgroup(struct zonefs_zone_data *zd,
>>> struct blk_zone *zone, *next, *end;
>>> const char *zgroup_name;
>>> char *file_name;
>>> - struct dentry *dir;
>>> + struct dentry *dir, *ret2;
>>> unsigned int n = 0;
>>> int ret;
>>>
>>> @@ -1523,8 +1531,11 @@ static int zonefs_create_zgroup(struct zonefs_zone_data *zd,
>>> zgroup_name = "seq";
>>>
>>> dir = zonefs_create_inode(sb->s_root, zgroup_name, NULL, type);
>>> - if (!dir) {
>>> - ret = -ENOMEM;
>>> + if (IS_ERR_OR_NULL(dir)) {
>>> + if (!dir)
>>> + ret = -ENOMEM;
>>
>> It would be cleaner to return ERR_PTR(-ENOMEM) instead of NULL in
>> zonefs_create_inode(). This way, this can simply be:
>> if (IS_ERR(dir)) {
>> ret = PTR_ERR(dir);
>> goto free;
>> }
>>
>> And the hunk below would be similar too.
>>
>
> Agreed, I'll update the patch. Or do you want to do it when squashing it
> into your "zonefs: fix zone report size in __zonefs_io_error()" patch?
If you can do the squashing, that would be nice too :)
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] zonefs: add sanity check for aggregated conventional zones
2022-11-04 12:06 ` Damien Le Moal
@ 2022-11-04 12:36 ` Johannes Thumshirn
0 siblings, 0 replies; 6+ messages in thread
From: Johannes Thumshirn @ 2022-11-04 12:36 UTC (permalink / raw)
To: Damien Le Moal; +Cc: linux-fsdevel@vger.kernel.org
On 04.11.22 13:06, Damien Le Moal wrote:
>> Agreed, I'll update the patch. Or do you want to do it when squashing it
>> into your "zonefs: fix zone report size in __zonefs_io_error()" patch?
>
> If you can do the squashing, that would be nice too :)
>
Will do, but I have to get some btrfs fixes done first.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] zonefs: add sanity check for aggregated conventional zones
2022-11-03 10:32 [PATCH] zonefs: add sanity check for aggregated conventional zones Johannes Thumshirn
2022-11-04 0:26 ` Damien Le Moal
@ 2022-11-07 7:58 ` Dan Carpenter
1 sibling, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2022-11-07 7:58 UTC (permalink / raw)
To: oe-kbuild, Johannes Thumshirn, Damien Le Moal
Cc: lkp, oe-kbuild-all, linux-fsdevel, Johannes Thumshirn
Hi Johannes,
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Johannes-Thumshirn/zonefs-add-sanity-check-for-aggregated-conventional-zones/20221103-183404
patch link: https://lore.kernel.org/r/f7e4afaca0eb337bf18231358b7e764d4cdf5c5a.1667471410.git.johannes.thumshirn%40wdc.com
patch subject: [PATCH] zonefs: add sanity check for aggregated conventional zones
config: ia64-randconfig-m031-20221104
compiler: ia64-linux-gcc (GCC) 12.1.0
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
New smatch warnings:
fs/zonefs/super.c:1411 zonefs_init_file_inode() warn: add some parenthesis here?
fs/zonefs/super.c:1411 zonefs_init_file_inode() warn: maybe use && instead of &
fs/zonefs/super.c:1496 zonefs_create_inode() error: uninitialized symbol 'ret'.
Old smatch warnings:
fs/zonefs/super.c:797 zonefs_file_dio_append() error: uninitialized symbol 'size'.
vim +1411 fs/zonefs/super.c
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1395
1da18a296f5ba4 Damien Le Moal 2022-04-12 1396 static int zonefs_init_file_inode(struct inode *inode, struct blk_zone *zone,
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1397 enum zonefs_ztype type)
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1398 {
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1399 struct super_block *sb = inode->i_sb;
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1400 struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1401 struct zonefs_inode_info *zi = ZONEFS_I(inode);
14bdb047a54d7a Damien Le Moal 2022-05-24 1402 int ret = 0;
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1403
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1404 inode->i_ino = zone->start >> sbi->s_zone_sectors_shift;
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1405 inode->i_mode = S_IFREG | sbi->s_perm;
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1406
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1407 zi->i_ztype = type;
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1408 zi->i_zsector = zone->start;
e3c3155bc95ab6 Johannes Thumshirn 2020-07-21 1409 zi->i_zone_size = zone->len << SECTOR_SHIFT;
4113036e1dcbb0 Johannes Thumshirn 2022-11-03 1410 if (zi->i_zone_size > bdev_zone_sectors(sb->s_bdev) << SECTOR_SHIFT &&
4113036e1dcbb0 Johannes Thumshirn 2022-11-03 @1411 !sbi->s_features & ZONEFS_F_AGGRCNV) {
Needs to be !(sbi->s_features & ZONEFS_F_AGGRCNV)) {
4113036e1dcbb0 Johannes Thumshirn 2022-11-03 1412 zonefs_err(sb,
4113036e1dcbb0 Johannes Thumshirn 2022-11-03 1413 "zone size %llu doesn't match device's zone sectors %llu\n",
4113036e1dcbb0 Johannes Thumshirn 2022-11-03 1414 zi->i_zone_size,
4113036e1dcbb0 Johannes Thumshirn 2022-11-03 1415 bdev_zone_sectors(sb->s_bdev) << SECTOR_SHIFT);
4113036e1dcbb0 Johannes Thumshirn 2022-11-03 1416 return -EINVAL;
4113036e1dcbb0 Johannes Thumshirn 2022-11-03 1417 }
e3c3155bc95ab6 Johannes Thumshirn 2020-07-21 1418
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1419 zi->i_max_size = min_t(loff_t, MAX_LFS_FILESIZE,
e3c3155bc95ab6 Johannes Thumshirn 2020-07-21 1420 zone->capacity << SECTOR_SHIFT);
ccf4ad7da0d9c3 Damien Le Moal 2020-03-20 1421 zi->i_wpoffset = zonefs_check_zone_condition(inode, zone, true, true);
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1422
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1423 inode->i_uid = sbi->s_uid;
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1424 inode->i_gid = sbi->s_gid;
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1425 inode->i_size = zi->i_wpoffset;
e3c3155bc95ab6 Johannes Thumshirn 2020-07-21 1426 inode->i_blocks = zi->i_max_size >> SECTOR_SHIFT;
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1427
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1428 inode->i_op = &zonefs_file_inode_operations;
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1429 inode->i_fop = &zonefs_file_operations;
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1430 inode->i_mapping->a_ops = &zonefs_file_aops;
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1431
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1432 sb->s_maxbytes = max(zi->i_max_size, sb->s_maxbytes);
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1433 sbi->s_blocks += zi->i_max_size >> sb->s_blocksize_bits;
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1434 sbi->s_used_blocks += zi->i_wpoffset >> sb->s_blocksize_bits;
1da18a296f5ba4 Damien Le Moal 2022-04-12 1435
87c9ce3ffec906 Damien Le Moal 2022-04-12 1436 mutex_lock(&zi->i_truncate_mutex);
87c9ce3ffec906 Damien Le Moal 2022-04-12 1437
1da18a296f5ba4 Damien Le Moal 2022-04-12 1438 /*
1da18a296f5ba4 Damien Le Moal 2022-04-12 1439 * For sequential zones, make sure that any open zone is closed first
1da18a296f5ba4 Damien Le Moal 2022-04-12 1440 * to ensure that the initial number of open zones is 0, in sync with
1da18a296f5ba4 Damien Le Moal 2022-04-12 1441 * the open zone accounting done when the mount option
1da18a296f5ba4 Damien Le Moal 2022-04-12 1442 * ZONEFS_MNTOPT_EXPLICIT_OPEN is used.
1da18a296f5ba4 Damien Le Moal 2022-04-12 1443 */
1da18a296f5ba4 Damien Le Moal 2022-04-12 1444 if (type == ZONEFS_ZTYPE_SEQ &&
1da18a296f5ba4 Damien Le Moal 2022-04-12 1445 (zone->cond == BLK_ZONE_COND_IMP_OPEN ||
1da18a296f5ba4 Damien Le Moal 2022-04-12 1446 zone->cond == BLK_ZONE_COND_EXP_OPEN)) {
1da18a296f5ba4 Damien Le Moal 2022-04-12 1447 ret = zonefs_zone_mgmt(inode, REQ_OP_ZONE_CLOSE);
87c9ce3ffec906 Damien Le Moal 2022-04-12 1448 if (ret)
87c9ce3ffec906 Damien Le Moal 2022-04-12 1449 goto unlock;
1da18a296f5ba4 Damien Le Moal 2022-04-12 1450 }
1da18a296f5ba4 Damien Le Moal 2022-04-12 1451
87c9ce3ffec906 Damien Le Moal 2022-04-12 1452 zonefs_account_active(inode);
87c9ce3ffec906 Damien Le Moal 2022-04-12 1453
87c9ce3ffec906 Damien Le Moal 2022-04-12 1454 unlock:
87c9ce3ffec906 Damien Le Moal 2022-04-12 1455 mutex_unlock(&zi->i_truncate_mutex);
87c9ce3ffec906 Damien Le Moal 2022-04-12 1456
14bdb047a54d7a Damien Le Moal 2022-05-24 1457 return ret;
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1458 }
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1459
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1460 static struct dentry *zonefs_create_inode(struct dentry *parent,
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1461 const char *name, struct blk_zone *zone,
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1462 enum zonefs_ztype type)
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1463 {
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1464 struct inode *dir = d_inode(parent);
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1465 struct dentry *dentry;
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1466 struct inode *inode;
1da18a296f5ba4 Damien Le Moal 2022-04-12 1467 int ret;
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1468
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1469 dentry = d_alloc_name(parent, name);
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1470 if (!dentry)
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1471 return NULL;
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1472
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1473 inode = new_inode(parent->d_sb);
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1474 if (!inode)
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1475 goto dput;
"ret" not initialized on this path.
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1476
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1477 inode->i_ctime = inode->i_mtime = inode->i_atime = dir->i_ctime;
1da18a296f5ba4 Damien Le Moal 2022-04-12 1478 if (zone) {
1da18a296f5ba4 Damien Le Moal 2022-04-12 1479 ret = zonefs_init_file_inode(inode, zone, type);
1da18a296f5ba4 Damien Le Moal 2022-04-12 1480 if (ret) {
1da18a296f5ba4 Damien Le Moal 2022-04-12 1481 iput(inode);
1da18a296f5ba4 Damien Le Moal 2022-04-12 1482 goto dput;
1da18a296f5ba4 Damien Le Moal 2022-04-12 1483 }
1da18a296f5ba4 Damien Le Moal 2022-04-12 1484 } else {
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1485 zonefs_init_dir_inode(dir, inode, type);
1da18a296f5ba4 Damien Le Moal 2022-04-12 1486 }
1da18a296f5ba4 Damien Le Moal 2022-04-12 1487
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1488 d_add(dentry, inode);
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1489 dir->i_size++;
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1490
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1491 return dentry;
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1492
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1493 dput:
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1494 dput(dentry);
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1495
4113036e1dcbb0 Johannes Thumshirn 2022-11-03 @1496 return ERR_PTR(ret);
8dcc1a9d90c10f Damien Le Moal 2019-12-25 1497 }
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-11-07 7:59 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-03 10:32 [PATCH] zonefs: add sanity check for aggregated conventional zones Johannes Thumshirn
2022-11-04 0:26 ` Damien Le Moal
2022-11-04 9:47 ` Johannes Thumshirn
2022-11-04 12:06 ` Damien Le Moal
2022-11-04 12:36 ` Johannes Thumshirn
2022-11-07 7:58 ` Dan Carpenter
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).