Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

change the calling conventions for vfs_parse_fs_string()

Absolute majority of callers are passing the 4th argument equal to
strlen() of the 3rd one.

Drop the v_size argument, add vfs_parse_fs_qstr() for the cases that
want independent length.

Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro b28f9eba 8f5ae30d

+49 -41
+9 -1
Documentation/filesystems/mount_api.rst
··· 506 506 507 507 * :: 508 508 509 + int vfs_parse_fs_qstr(struct fs_context *fc, const char *key, 510 + const struct qstr *value); 511 + 512 + A wrapper around vfs_parse_fs_param() that copies the value string it is 513 + passed. 514 + 515 + * :: 516 + 509 517 int vfs_parse_fs_string(struct fs_context *fc, const char *key, 510 - const char *value, size_t v_size); 518 + const char *value); 511 519 512 520 A wrapper around vfs_parse_fs_param() that copies the value string it is 513 521 passed.
+12
Documentation/filesystems/porting.rst
··· 1285 1285 The vm_area_desc provides the minimum required information for a filesystem 1286 1286 to initialise state upon memory mapping of a file-backed region, and output 1287 1287 parameters for the file system to set this state. 1288 + 1289 + --- 1290 + 1291 + **mandatory** 1292 + 1293 + Calling conventions for vfs_parse_fs_string() have changed; it does *not* 1294 + take length anymore (value ? strlen(value) : 0 is used). If you want 1295 + a different length, use 1296 + 1297 + vfs_parse_fs_qstr(fc, key, &QSTR_LEN(value, len)) 1298 + 1299 + instead.
+2 -7
drivers/gpu/drm/i915/gem/i915_gemfs.c
··· 11 11 #include "i915_gemfs.h" 12 12 #include "i915_utils.h" 13 13 14 - static int add_param(struct fs_context *fc, const char *key, const char *val) 15 - { 16 - return vfs_parse_fs_string(fc, key, val, strlen(val)); 17 - } 18 - 19 14 void i915_gemfs_init(struct drm_i915_private *i915) 20 15 { 21 16 struct file_system_type *type; ··· 43 48 fc = fs_context_for_mount(type, SB_KERNMOUNT); 44 49 if (IS_ERR(fc)) 45 50 goto err; 46 - ret = add_param(fc, "source", "tmpfs"); 51 + ret = vfs_parse_fs_string(fc, "source", "tmpfs"); 47 52 if (!ret) 48 - ret = add_param(fc, "huge", "within_size"); 53 + ret = vfs_parse_fs_string(fc, "huge", "within_size"); 49 54 if (!ret) 50 55 gemfs = fc_mount_longterm(fc); 51 56 put_fs_context(fc);
+2 -7
drivers/gpu/drm/v3d/v3d_gemfs.c
··· 7 7 8 8 #include "v3d_drv.h" 9 9 10 - static int add_param(struct fs_context *fc, const char *key, const char *val) 11 - { 12 - return vfs_parse_fs_string(fc, key, val, strlen(val)); 13 - } 14 - 15 10 void v3d_gemfs_init(struct v3d_dev *v3d) 16 11 { 17 12 struct file_system_type *type; ··· 33 38 fc = fs_context_for_mount(type, SB_KERNMOUNT); 34 39 if (IS_ERR(fc)) 35 40 goto err; 36 - ret = add_param(fc, "source", "tmpfs"); 41 + ret = vfs_parse_fs_string(fc, "source", "tmpfs"); 37 42 if (!ret) 38 - ret = add_param(fc, "huge", "within_size"); 43 + ret = vfs_parse_fs_string(fc, "huge", "within_size"); 39 44 if (!ret) 40 45 gemfs = fc_mount_longterm(fc); 41 46 put_fs_context(fc);
+2 -1
fs/afs/mntpt.c
··· 137 137 138 138 ret = -EINVAL; 139 139 if (content[size - 1] == '.') 140 - ret = vfs_parse_fs_string(fc, "source", content, size - 1); 140 + ret = vfs_parse_fs_qstr(fc, "source", 141 + &QSTR_LEN(content, size - 1)); 141 142 do_delayed_call(&cleanup); 142 143 if (ret < 0) 143 144 return ret;
+7 -10
fs/fs_context.c
··· 161 161 EXPORT_SYMBOL(vfs_parse_fs_param); 162 162 163 163 /** 164 - * vfs_parse_fs_string - Convenience function to just parse a string. 164 + * vfs_parse_fs_qstr - Convenience function to just parse a string. 165 165 * @fc: Filesystem context. 166 166 * @key: Parameter name. 167 167 * @value: Default value. 168 - * @v_size: Maximum number of bytes in the value. 169 168 */ 170 - int vfs_parse_fs_string(struct fs_context *fc, const char *key, 171 - const char *value, size_t v_size) 169 + int vfs_parse_fs_qstr(struct fs_context *fc, const char *key, 170 + const struct qstr *value) 172 171 { 173 172 int ret; 174 173 175 174 struct fs_parameter param = { 176 175 .key = key, 177 176 .type = fs_value_is_flag, 178 - .size = v_size, 177 + .size = value ? value->len : 0, 179 178 }; 180 179 181 180 if (value) { 182 - param.string = kmemdup_nul(value, v_size, GFP_KERNEL); 181 + param.string = kmemdup_nul(value->name, value->len, GFP_KERNEL); 183 182 if (!param.string) 184 183 return -ENOMEM; 185 184 param.type = fs_value_is_string; ··· 188 189 kfree(param.string); 189 190 return ret; 190 191 } 191 - EXPORT_SYMBOL(vfs_parse_fs_string); 192 + EXPORT_SYMBOL(vfs_parse_fs_qstr); 192 193 193 194 /** 194 195 * vfs_parse_monolithic_sep - Parse key[=val][,key[=val]]* mount data ··· 217 218 218 219 while ((key = sep(&options)) != NULL) { 219 220 if (*key) { 220 - size_t v_len = 0; 221 221 char *value = strchr(key, '='); 222 222 223 223 if (value) { 224 224 if (unlikely(value == key)) 225 225 continue; 226 226 *value++ = 0; 227 - v_len = strlen(value); 228 227 } 229 - ret = vfs_parse_fs_string(fc, key, value, v_len); 228 + ret = vfs_parse_fs_string(fc, key, value); 230 229 if (ret < 0) 231 230 break; 232 231 }
+3 -5
fs/namespace.c
··· 1281 1281 return ERR_CAST(fc); 1282 1282 1283 1283 if (name) 1284 - ret = vfs_parse_fs_string(fc, "source", 1285 - name, strlen(name)); 1284 + ret = vfs_parse_fs_string(fc, "source", name); 1286 1285 if (!ret) 1287 1286 ret = parse_monolithic_mount_data(fc, data); 1288 1287 if (!ret) ··· 3792 3793 fc->oldapi = true; 3793 3794 3794 3795 if (subtype) 3795 - err = vfs_parse_fs_string(fc, "subtype", 3796 - subtype, strlen(subtype)); 3796 + err = vfs_parse_fs_string(fc, "subtype", subtype); 3797 3797 if (!err && name) 3798 - err = vfs_parse_fs_string(fc, "source", name, strlen(name)); 3798 + err = vfs_parse_fs_string(fc, "source", name); 3799 3799 if (!err) 3800 3800 err = parse_monolithic_mount_data(fc, data); 3801 3801 if (!err && !mount_capable(fc))
+1 -2
fs/nfs/fs_context.c
··· 1269 1269 int ret; 1270 1270 1271 1271 data->context[NFS_MAX_CONTEXT_LEN] = '\0'; 1272 - ret = vfs_parse_fs_string(fc, "context", 1273 - data->context, strlen(data->context)); 1272 + ret = vfs_parse_fs_string(fc, "context", data->context); 1274 1273 if (ret < 0) 1275 1274 return ret; 1276 1275 #else
+2 -1
fs/nfs/namespace.c
··· 290 290 nfs_errorf(fc, "NFS: Couldn't determine submount pathname"); 291 291 ret = PTR_ERR(p); 292 292 } else { 293 - ret = vfs_parse_fs_string(fc, "source", p, buffer + 4096 - p); 293 + ret = vfs_parse_fs_qstr(fc, "source", 294 + &QSTR_LEN(p, buffer + 4096 - p)); 294 295 if (!ret) 295 296 ret = vfs_get_tree(fc); 296 297 }
+1 -3
fs/smb/client/fs_context.c
··· 773 773 } 774 774 775 775 776 - len = 0; 777 776 value = strchr(key, '='); 778 777 if (value) { 779 778 if (value == key) 780 779 continue; 781 780 *value++ = 0; 782 - len = strlen(value); 783 781 } 784 782 785 - ret = vfs_parse_fs_string(fc, key, value, len); 783 + ret = vfs_parse_fs_string(fc, key, value); 786 784 if (ret < 0) 787 785 break; 788 786 }
+7 -2
include/linux/fs_context.h
··· 134 134 135 135 extern struct fs_context *vfs_dup_fs_context(struct fs_context *fc); 136 136 extern int vfs_parse_fs_param(struct fs_context *fc, struct fs_parameter *param); 137 - extern int vfs_parse_fs_string(struct fs_context *fc, const char *key, 138 - const char *value, size_t v_size); 137 + extern int vfs_parse_fs_qstr(struct fs_context *fc, const char *key, 138 + const struct qstr *value); 139 + static inline int vfs_parse_fs_string(struct fs_context *fc, const char *key, 140 + const char *value) 141 + { 142 + return vfs_parse_fs_qstr(fc, key, value ? &QSTR(value) : NULL); 143 + } 139 144 int vfs_parse_monolithic_sep(struct fs_context *fc, void *data, 140 145 char *(*sep)(char **)); 141 146 extern int generic_parse_monolithic(struct fs_context *fc, void *data);
+1 -2
kernel/trace/trace.c
··· 10201 10201 10202 10202 pr_warn("NOTICE: Automounting of tracing to debugfs is deprecated and will be removed in 2030\n"); 10203 10203 10204 - ret = vfs_parse_fs_string(fc, "source", 10205 - "tracefs", strlen("tracefs")); 10204 + ret = vfs_parse_fs_string(fc, "source", "tracefs"); 10206 10205 if (!ret) 10207 10206 mnt = fc_mount(fc); 10208 10207 else