diff options
| -rw-r--r-- | fs/overlayfs/Kconfig | 17 | ||||
| -rw-r--r-- | fs/overlayfs/ovl_entry.h | 1 | ||||
| -rw-r--r-- | fs/overlayfs/super.c | 73 |
3 files changed, 88 insertions, 3 deletions
diff --git a/fs/overlayfs/Kconfig b/fs/overlayfs/Kconfig index ce6ff5a0a6e4..17032631c5cf 100644 --- a/fs/overlayfs/Kconfig +++ b/fs/overlayfs/Kconfig | |||
| @@ -86,3 +86,20 @@ config OVERLAY_FS_NFS_EXPORT | |||
| 86 | case basis with the "nfs_export=on" mount option. | 86 | case basis with the "nfs_export=on" mount option. |
| 87 | 87 | ||
| 88 | Say N unless you fully understand the consequences. | 88 | Say N unless you fully understand the consequences. |
| 89 | |||
| 90 | config OVERLAY_FS_XINO_AUTO | ||
| 91 | bool "Overlayfs: auto enable inode number mapping" | ||
| 92 | default n | ||
| 93 | depends on OVERLAY_FS | ||
| 94 | help | ||
| 95 | If this config option is enabled then overlay filesystems will use | ||
| 96 | unused high bits in undelying filesystem inode numbers to map all | ||
| 97 | inodes to a unified address space. The mapped 64bit inode numbers | ||
| 98 | might not be compatible with applications that expect 32bit inodes. | ||
| 99 | |||
| 100 | If compatibility with applications that expect 32bit inodes is not an | ||
| 101 | issue, then it is safe and recommended to say Y here. | ||
| 102 | |||
| 103 | For more information, see Documentation/filesystems/overlayfs.txt | ||
| 104 | |||
| 105 | If unsure, say N. | ||
diff --git a/fs/overlayfs/ovl_entry.h b/fs/overlayfs/ovl_entry.h index 620bd20f9a22..41655a7d6894 100644 --- a/fs/overlayfs/ovl_entry.h +++ b/fs/overlayfs/ovl_entry.h | |||
| @@ -18,6 +18,7 @@ struct ovl_config { | |||
| 18 | const char *redirect_mode; | 18 | const char *redirect_mode; |
| 19 | bool index; | 19 | bool index; |
| 20 | bool nfs_export; | 20 | bool nfs_export; |
| 21 | int xino; | ||
| 21 | }; | 22 | }; |
| 22 | 23 | ||
| 23 | struct ovl_sb { | 24 | struct ovl_sb { |
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index d7284444f404..e8551c97de51 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c | |||
| @@ -51,6 +51,11 @@ module_param_named(nfs_export, ovl_nfs_export_def, bool, 0644); | |||
| 51 | MODULE_PARM_DESC(ovl_nfs_export_def, | 51 | MODULE_PARM_DESC(ovl_nfs_export_def, |
| 52 | "Default to on or off for the NFS export feature"); | 52 | "Default to on or off for the NFS export feature"); |
| 53 | 53 | ||
| 54 | static bool ovl_xino_auto_def = IS_ENABLED(CONFIG_OVERLAY_FS_XINO_AUTO); | ||
| 55 | module_param_named(xino_auto, ovl_xino_auto_def, bool, 0644); | ||
| 56 | MODULE_PARM_DESC(ovl_xino_auto_def, | ||
| 57 | "Auto enable xino feature"); | ||
| 58 | |||
| 54 | static void ovl_entry_stack_free(struct ovl_entry *oe) | 59 | static void ovl_entry_stack_free(struct ovl_entry *oe) |
| 55 | { | 60 | { |
| 56 | unsigned int i; | 61 | unsigned int i; |
| @@ -327,6 +332,23 @@ static const char *ovl_redirect_mode_def(void) | |||
| 327 | return ovl_redirect_dir_def ? "on" : "off"; | 332 | return ovl_redirect_dir_def ? "on" : "off"; |
| 328 | } | 333 | } |
| 329 | 334 | ||
| 335 | enum { | ||
| 336 | OVL_XINO_OFF, | ||
| 337 | OVL_XINO_AUTO, | ||
| 338 | OVL_XINO_ON, | ||
| 339 | }; | ||
| 340 | |||
| 341 | static const char * const ovl_xino_str[] = { | ||
| 342 | "off", | ||
| 343 | "auto", | ||
| 344 | "on", | ||
| 345 | }; | ||
| 346 | |||
| 347 | static inline int ovl_xino_def(void) | ||
| 348 | { | ||
| 349 | return ovl_xino_auto_def ? OVL_XINO_AUTO : OVL_XINO_OFF; | ||
| 350 | } | ||
| 351 | |||
| 330 | /** | 352 | /** |
| 331 | * ovl_show_options | 353 | * ovl_show_options |
| 332 | * | 354 | * |
| @@ -352,6 +374,8 @@ static int ovl_show_options(struct seq_file *m, struct dentry *dentry) | |||
| 352 | if (ofs->config.nfs_export != ovl_nfs_export_def) | 374 | if (ofs->config.nfs_export != ovl_nfs_export_def) |
| 353 | seq_printf(m, ",nfs_export=%s", ofs->config.nfs_export ? | 375 | seq_printf(m, ",nfs_export=%s", ofs->config.nfs_export ? |
| 354 | "on" : "off"); | 376 | "on" : "off"); |
| 377 | if (ofs->config.xino != ovl_xino_def()) | ||
| 378 | seq_printf(m, ",xino=%s", ovl_xino_str[ofs->config.xino]); | ||
| 355 | return 0; | 379 | return 0; |
| 356 | } | 380 | } |
| 357 | 381 | ||
| @@ -386,6 +410,9 @@ enum { | |||
| 386 | OPT_INDEX_OFF, | 410 | OPT_INDEX_OFF, |
| 387 | OPT_NFS_EXPORT_ON, | 411 | OPT_NFS_EXPORT_ON, |
| 388 | OPT_NFS_EXPORT_OFF, | 412 | OPT_NFS_EXPORT_OFF, |
| 413 | OPT_XINO_ON, | ||
| 414 | OPT_XINO_OFF, | ||
| 415 | OPT_XINO_AUTO, | ||
| 389 | OPT_ERR, | 416 | OPT_ERR, |
| 390 | }; | 417 | }; |
| 391 | 418 | ||
| @@ -399,6 +426,9 @@ static const match_table_t ovl_tokens = { | |||
| 399 | {OPT_INDEX_OFF, "index=off"}, | 426 | {OPT_INDEX_OFF, "index=off"}, |
| 400 | {OPT_NFS_EXPORT_ON, "nfs_export=on"}, | 427 | {OPT_NFS_EXPORT_ON, "nfs_export=on"}, |
| 401 | {OPT_NFS_EXPORT_OFF, "nfs_export=off"}, | 428 | {OPT_NFS_EXPORT_OFF, "nfs_export=off"}, |
| 429 | {OPT_XINO_ON, "xino=on"}, | ||
| 430 | {OPT_XINO_OFF, "xino=off"}, | ||
| 431 | {OPT_XINO_AUTO, "xino=auto"}, | ||
| 402 | {OPT_ERR, NULL} | 432 | {OPT_ERR, NULL} |
| 403 | }; | 433 | }; |
| 404 | 434 | ||
| @@ -513,6 +543,18 @@ static int ovl_parse_opt(char *opt, struct ovl_config *config) | |||
| 513 | config->nfs_export = false; | 543 | config->nfs_export = false; |
| 514 | break; | 544 | break; |
| 515 | 545 | ||
| 546 | case OPT_XINO_ON: | ||
| 547 | config->xino = OVL_XINO_ON; | ||
| 548 | break; | ||
| 549 | |||
| 550 | case OPT_XINO_OFF: | ||
| 551 | config->xino = OVL_XINO_OFF; | ||
| 552 | break; | ||
| 553 | |||
| 554 | case OPT_XINO_AUTO: | ||
| 555 | config->xino = OVL_XINO_AUTO; | ||
| 556 | break; | ||
| 557 | |||
| 516 | default: | 558 | default: |
| 517 | pr_err("overlayfs: unrecognized mount option \"%s\" or missing value\n", p); | 559 | pr_err("overlayfs: unrecognized mount option \"%s\" or missing value\n", p); |
| 518 | return -EINVAL; | 560 | return -EINVAL; |
| @@ -1197,9 +1239,31 @@ static int ovl_get_lower_layers(struct ovl_fs *ofs, struct path *stack, | |||
| 1197 | ofs->numlower++; | 1239 | ofs->numlower++; |
| 1198 | } | 1240 | } |
| 1199 | 1241 | ||
| 1200 | /* When all layers on same fs, overlay can use real inode numbers */ | 1242 | /* |
| 1201 | if (!ofs->numlowerfs || (ofs->numlowerfs == 1 && !ofs->upper_mnt)) | 1243 | * When all layers on same fs, overlay can use real inode numbers. |
| 1244 | * With mount option "xino=on", mounter declares that there are enough | ||
| 1245 | * free high bits in underlying fs to hold the unique fsid. | ||
| 1246 | * If overlayfs does encounter underlying inodes using the high xino | ||
| 1247 | * bits reserved for fsid, it emits a warning and uses the original | ||
| 1248 | * inode number. | ||
| 1249 | */ | ||
| 1250 | if (!ofs->numlowerfs || (ofs->numlowerfs == 1 && !ofs->upper_mnt)) { | ||
| 1202 | ofs->xino_bits = 0; | 1251 | ofs->xino_bits = 0; |
| 1252 | ofs->config.xino = OVL_XINO_OFF; | ||
| 1253 | } else if (ofs->config.xino == OVL_XINO_ON && !ofs->xino_bits) { | ||
| 1254 | /* | ||
| 1255 | * This is a roundup of number of bits needed for numlowerfs+1 | ||
| 1256 | * (i.e. ilog2(numlowerfs+1 - 1) + 1). fsid 0 is reserved for | ||
| 1257 | * upper fs even with non upper overlay. | ||
| 1258 | */ | ||
| 1259 | BUILD_BUG_ON(ilog2(OVL_MAX_STACK) > 31); | ||
| 1260 | ofs->xino_bits = ilog2(ofs->numlowerfs) + 1; | ||
| 1261 | } | ||
| 1262 | |||
| 1263 | if (ofs->xino_bits) { | ||
| 1264 | pr_info("overlayfs: \"xino\" feature enabled using %d upper inode bits.\n", | ||
| 1265 | ofs->xino_bits); | ||
| 1266 | } | ||
| 1203 | 1267 | ||
| 1204 | err = 0; | 1268 | err = 0; |
| 1205 | out: | 1269 | out: |
| @@ -1311,6 +1375,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) | |||
| 1311 | 1375 | ||
| 1312 | ofs->config.index = ovl_index_def; | 1376 | ofs->config.index = ovl_index_def; |
| 1313 | ofs->config.nfs_export = ovl_nfs_export_def; | 1377 | ofs->config.nfs_export = ovl_nfs_export_def; |
| 1378 | ofs->config.xino = ovl_xino_def(); | ||
| 1314 | err = ovl_parse_opt((char *) data, &ofs->config); | 1379 | err = ovl_parse_opt((char *) data, &ofs->config); |
| 1315 | if (err) | 1380 | if (err) |
| 1316 | goto out_err; | 1381 | goto out_err; |
| @@ -1325,7 +1390,9 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) | |||
| 1325 | sb->s_stack_depth = 0; | 1390 | sb->s_stack_depth = 0; |
| 1326 | sb->s_maxbytes = MAX_LFS_FILESIZE; | 1391 | sb->s_maxbytes = MAX_LFS_FILESIZE; |
| 1327 | /* Assume underlaying fs uses 32bit inodes unless proven otherwise */ | 1392 | /* Assume underlaying fs uses 32bit inodes unless proven otherwise */ |
| 1328 | ofs->xino_bits = BITS_PER_LONG - 32; | 1393 | if (ofs->config.xino != OVL_XINO_OFF) |
| 1394 | ofs->xino_bits = BITS_PER_LONG - 32; | ||
| 1395 | |||
| 1329 | if (ofs->config.upperdir) { | 1396 | if (ofs->config.upperdir) { |
| 1330 | if (!ofs->config.workdir) { | 1397 | if (!ofs->config.workdir) { |
| 1331 | pr_err("overlayfs: missing 'workdir'\n"); | 1398 | pr_err("overlayfs: missing 'workdir'\n"); |
