@@ -894,22 +894,21 @@ static inline int btrfs_may_create(struct mnt_idmap *idmap,
894
894
*/
895
895
static noinline int btrfs_mksubvol (const struct path * parent ,
896
896
struct mnt_idmap * idmap ,
897
- const char * name , int namelen ,
898
- struct btrfs_root * snap_src ,
897
+ struct qstr * qname , struct btrfs_root * snap_src ,
899
898
bool readonly ,
900
899
struct btrfs_qgroup_inherit * inherit )
901
900
{
902
901
struct inode * dir = d_inode (parent -> dentry );
903
902
struct btrfs_fs_info * fs_info = inode_to_fs_info (dir );
904
903
struct dentry * dentry ;
905
- struct fscrypt_str name_str = FSTR_INIT ((char * )name , namelen );
904
+ struct fscrypt_str name_str = FSTR_INIT ((char * )qname -> name , qname -> len );
906
905
int ret ;
907
906
908
907
ret = down_write_killable_nested (& dir -> i_rwsem , I_MUTEX_PARENT );
909
908
if (ret == - EINTR )
910
909
return ret ;
911
910
912
- dentry = lookup_one (idmap , & QSTR_LEN ( name , namelen ) , parent -> dentry );
911
+ dentry = lookup_one (idmap , qname , parent -> dentry );
913
912
ret = PTR_ERR (dentry );
914
913
if (IS_ERR (dentry ))
915
914
goto out_unlock ;
@@ -949,7 +948,7 @@ static noinline int btrfs_mksubvol(const struct path *parent,
949
948
950
949
static noinline int btrfs_mksnapshot (const struct path * parent ,
951
950
struct mnt_idmap * idmap ,
952
- const char * name , int namelen ,
951
+ struct qstr * qname ,
953
952
struct btrfs_root * root ,
954
953
bool readonly ,
955
954
struct btrfs_qgroup_inherit * inherit )
@@ -976,8 +975,8 @@ static noinline int btrfs_mksnapshot(const struct path *parent,
976
975
977
976
btrfs_wait_ordered_extents (root , U64_MAX , NULL );
978
977
979
- ret = btrfs_mksubvol (parent , idmap , name , namelen ,
980
- root , readonly , inherit );
978
+ ret = btrfs_mksubvol (parent , idmap , qname , root , readonly , inherit );
979
+
981
980
atomic_dec (& root -> snapshot_force_cow );
982
981
out :
983
982
btrfs_drew_read_unlock (& root -> snapshot_lock );
@@ -1187,8 +1186,8 @@ static noinline int __btrfs_ioctl_snap_create(struct file *file,
1187
1186
bool readonly ,
1188
1187
struct btrfs_qgroup_inherit * inherit )
1189
1188
{
1190
- int namelen ;
1191
1189
int ret = 0 ;
1190
+ struct qstr qname = QSTR_INIT (name , strlen (name ));
1192
1191
1193
1192
if (!S_ISDIR (file_inode (file )-> i_mode ))
1194
1193
return - ENOTDIR ;
@@ -1197,21 +1196,20 @@ static noinline int __btrfs_ioctl_snap_create(struct file *file,
1197
1196
if (ret )
1198
1197
goto out ;
1199
1198
1200
- namelen = strlen (name );
1201
1199
if (strchr (name , '/' )) {
1202
1200
ret = - EINVAL ;
1203
1201
goto out_drop_write ;
1204
1202
}
1205
1203
1206
- if (name [0 ] == '.' &&
1207
- (namelen == 1 || (name [1 ] == '.' && namelen == 2 ))) {
1204
+ if (qname . name [0 ] == '.' &&
1205
+ (qname . len == 1 || (qname . name [1 ] == '.' && qname . len == 2 ))) {
1208
1206
ret = - EEXIST ;
1209
1207
goto out_drop_write ;
1210
1208
}
1211
1209
1212
1210
if (subvol ) {
1213
- ret = btrfs_mksubvol (& file -> f_path , idmap , name ,
1214
- namelen , NULL , readonly , inherit );
1211
+ ret = btrfs_mksubvol (& file -> f_path , idmap , & qname , NULL ,
1212
+ readonly , inherit );
1215
1213
} else {
1216
1214
CLASS (fd , src )(fd );
1217
1215
struct inode * src_inode ;
@@ -1241,8 +1239,7 @@ static noinline int __btrfs_ioctl_snap_create(struct file *file,
1241
1239
*/
1242
1240
ret = - EINVAL ;
1243
1241
} else {
1244
- ret = btrfs_mksnapshot (& file -> f_path , idmap ,
1245
- name , namelen ,
1242
+ ret = btrfs_mksnapshot (& file -> f_path , idmap , & qname ,
1246
1243
BTRFS_I (src_inode )-> root ,
1247
1244
readonly , inherit );
1248
1245
}
0 commit comments