1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright (C) 2011 Novell Inc.
7 #include <uapi/linux/magic.h>
9 #include <linux/namei.h>
10 #include <linux/xattr.h>
11 #include <linux/mount.h>
12 #include <linux/parser.h>
13 #include <linux/module.h>
14 #include <linux/statfs.h>
15 #include <linux/seq_file.h>
16 #include <linux/posix_acl_xattr.h>
17 #include <linux/exportfs.h>
18 #include "overlayfs.h"
20 MODULE_AUTHOR("Miklos Szeredi <miklos@szeredi.hu>");
21 MODULE_DESCRIPTION("Overlay filesystem");
22 MODULE_LICENSE("GPL");
27 #define OVL_MAX_STACK 500
29 static bool ovl_redirect_dir_def
= IS_ENABLED(CONFIG_OVERLAY_FS_REDIRECT_DIR
);
30 module_param_named(redirect_dir
, ovl_redirect_dir_def
, bool, 0644);
31 MODULE_PARM_DESC(ovl_redirect_dir_def
,
32 "Default to on or off for the redirect_dir feature");
34 static bool ovl_redirect_always_follow
=
35 IS_ENABLED(CONFIG_OVERLAY_FS_REDIRECT_ALWAYS_FOLLOW
);
36 module_param_named(redirect_always_follow
, ovl_redirect_always_follow
,
38 MODULE_PARM_DESC(ovl_redirect_always_follow
,
39 "Follow redirects even if redirect_dir feature is turned off");
41 static bool ovl_index_def
= IS_ENABLED(CONFIG_OVERLAY_FS_INDEX
);
42 module_param_named(index
, ovl_index_def
, bool, 0644);
43 MODULE_PARM_DESC(ovl_index_def
,
44 "Default to on or off for the inodes index feature");
46 static bool ovl_nfs_export_def
= IS_ENABLED(CONFIG_OVERLAY_FS_NFS_EXPORT
);
47 module_param_named(nfs_export
, ovl_nfs_export_def
, bool, 0644);
48 MODULE_PARM_DESC(ovl_nfs_export_def
,
49 "Default to on or off for the NFS export feature");
51 static bool ovl_xino_auto_def
= IS_ENABLED(CONFIG_OVERLAY_FS_XINO_AUTO
);
52 module_param_named(xino_auto
, ovl_xino_auto_def
, bool, 0644);
53 MODULE_PARM_DESC(ovl_xino_auto_def
,
54 "Auto enable xino feature");
56 static void ovl_entry_stack_free(struct ovl_entry
*oe
)
60 for (i
= 0; i
< oe
->numlower
; i
++)
61 dput(oe
->lowerstack
[i
].dentry
);
64 static bool ovl_metacopy_def
= IS_ENABLED(CONFIG_OVERLAY_FS_METACOPY
);
65 module_param_named(metacopy
, ovl_metacopy_def
, bool, 0644);
66 MODULE_PARM_DESC(ovl_metacopy_def
,
67 "Default to on or off for the metadata only copy up feature");
69 static void ovl_dentry_release(struct dentry
*dentry
)
71 struct ovl_entry
*oe
= dentry
->d_fsdata
;
74 ovl_entry_stack_free(oe
);
79 static struct dentry
*ovl_d_real(struct dentry
*dentry
,
80 const struct inode
*inode
)
84 /* It's an overlay file */
85 if (inode
&& d_inode(dentry
) == inode
)
88 if (!d_is_reg(dentry
)) {
89 if (!inode
|| inode
== d_inode(dentry
))
94 real
= ovl_dentry_upper(dentry
);
95 if (real
&& (inode
== d_inode(real
)))
98 if (real
&& !inode
&& ovl_has_upperdata(d_inode(dentry
)))
101 real
= ovl_dentry_lowerdata(dentry
);
105 /* Handle recursion */
106 real
= d_real(real
, inode
);
108 if (!inode
|| inode
== d_inode(real
))
111 WARN(1, "ovl_d_real(%pd4, %s:%lu): real dentry not found\n", dentry
,
112 inode
? inode
->i_sb
->s_id
: "NULL", inode
? inode
->i_ino
: 0);
116 static int ovl_dentry_revalidate(struct dentry
*dentry
, unsigned int flags
)
118 struct ovl_entry
*oe
= dentry
->d_fsdata
;
122 for (i
= 0; i
< oe
->numlower
; i
++) {
123 struct dentry
*d
= oe
->lowerstack
[i
].dentry
;
125 if (d
->d_flags
& DCACHE_OP_REVALIDATE
) {
126 ret
= d
->d_op
->d_revalidate(d
, flags
);
130 if (!(flags
& LOOKUP_RCU
))
139 static int ovl_dentry_weak_revalidate(struct dentry
*dentry
, unsigned int flags
)
141 struct ovl_entry
*oe
= dentry
->d_fsdata
;
145 for (i
= 0; i
< oe
->numlower
; i
++) {
146 struct dentry
*d
= oe
->lowerstack
[i
].dentry
;
148 if (d
->d_flags
& DCACHE_OP_WEAK_REVALIDATE
) {
149 ret
= d
->d_op
->d_weak_revalidate(d
, flags
);
157 static const struct dentry_operations ovl_dentry_operations
= {
158 .d_release
= ovl_dentry_release
,
159 .d_real
= ovl_d_real
,
162 static const struct dentry_operations ovl_reval_dentry_operations
= {
163 .d_release
= ovl_dentry_release
,
164 .d_real
= ovl_d_real
,
165 .d_revalidate
= ovl_dentry_revalidate
,
166 .d_weak_revalidate
= ovl_dentry_weak_revalidate
,
169 static struct kmem_cache
*ovl_inode_cachep
;
171 static struct inode
*ovl_alloc_inode(struct super_block
*sb
)
173 struct ovl_inode
*oi
= kmem_cache_alloc(ovl_inode_cachep
, GFP_KERNEL
);
182 oi
->__upperdentry
= NULL
;
184 oi
->lowerdata
= NULL
;
185 mutex_init(&oi
->lock
);
187 return &oi
->vfs_inode
;
190 static void ovl_free_inode(struct inode
*inode
)
192 struct ovl_inode
*oi
= OVL_I(inode
);
195 mutex_destroy(&oi
->lock
);
196 kmem_cache_free(ovl_inode_cachep
, oi
);
199 static void ovl_destroy_inode(struct inode
*inode
)
201 struct ovl_inode
*oi
= OVL_I(inode
);
203 dput(oi
->__upperdentry
);
205 if (S_ISDIR(inode
->i_mode
))
206 ovl_dir_cache_free(inode
);
211 static void ovl_free_fs(struct ovl_fs
*ofs
)
215 iput(ofs
->indexdir_trap
);
216 iput(ofs
->workdir_trap
);
217 iput(ofs
->upperdir_trap
);
220 if (ofs
->workdir_locked
)
221 ovl_inuse_unlock(ofs
->workbasedir
);
222 dput(ofs
->workbasedir
);
223 if (ofs
->upperdir_locked
)
224 ovl_inuse_unlock(ofs
->upper_mnt
->mnt_root
);
225 mntput(ofs
->upper_mnt
);
226 for (i
= 0; i
< ofs
->numlower
; i
++) {
227 iput(ofs
->lower_layers
[i
].trap
);
228 mntput(ofs
->lower_layers
[i
].mnt
);
230 for (i
= 0; i
< ofs
->numlowerfs
; i
++)
231 free_anon_bdev(ofs
->lower_fs
[i
].pseudo_dev
);
232 kfree(ofs
->lower_layers
);
233 kfree(ofs
->lower_fs
);
235 kfree(ofs
->config
.lowerdir
);
236 kfree(ofs
->config
.upperdir
);
237 kfree(ofs
->config
.workdir
);
238 kfree(ofs
->config
.redirect_mode
);
239 if (ofs
->creator_cred
)
240 put_cred(ofs
->creator_cred
);
244 static void ovl_put_super(struct super_block
*sb
)
246 struct ovl_fs
*ofs
= sb
->s_fs_info
;
251 /* Sync real dirty inodes in upper filesystem (if it exists) */
252 static int ovl_sync_fs(struct super_block
*sb
, int wait
)
254 struct ovl_fs
*ofs
= sb
->s_fs_info
;
255 struct super_block
*upper_sb
;
262 * If this is a sync(2) call or an emergency sync, all the super blocks
263 * will be iterated, including upper_sb, so no need to do anything.
265 * If this is a syncfs(2) call, then we do need to call
266 * sync_filesystem() on upper_sb, but enough if we do it when being
267 * called with wait == 1.
272 upper_sb
= ofs
->upper_mnt
->mnt_sb
;
274 down_read(&upper_sb
->s_umount
);
275 ret
= sync_filesystem(upper_sb
);
276 up_read(&upper_sb
->s_umount
);
283 * @sb: The overlayfs super block
284 * @buf: The struct kstatfs to fill in with stats
286 * Get the filesystem statistics. As writes always target the upper layer
287 * filesystem pass the statfs to the upper filesystem (if it exists)
289 static int ovl_statfs(struct dentry
*dentry
, struct kstatfs
*buf
)
291 struct ovl_fs
*ofs
= dentry
->d_sb
->s_fs_info
;
292 struct dentry
*root_dentry
= dentry
->d_sb
->s_root
;
296 ovl_path_real(root_dentry
, &path
);
298 err
= vfs_statfs(&path
, buf
);
300 buf
->f_namelen
= ofs
->namelen
;
301 buf
->f_type
= OVERLAYFS_SUPER_MAGIC
;
307 /* Will this overlay be forced to mount/remount ro? */
308 static bool ovl_force_readonly(struct ovl_fs
*ofs
)
310 return (!ofs
->upper_mnt
|| !ofs
->workdir
);
313 static const char *ovl_redirect_mode_def(void)
315 return ovl_redirect_dir_def
? "on" : "off";
324 static const char * const ovl_xino_str
[] = {
330 static inline int ovl_xino_def(void)
332 return ovl_xino_auto_def
? OVL_XINO_AUTO
: OVL_XINO_OFF
;
338 * Prints the mount options for a given superblock.
339 * Returns zero; does not fail.
341 static int ovl_show_options(struct seq_file
*m
, struct dentry
*dentry
)
343 struct super_block
*sb
= dentry
->d_sb
;
344 struct ovl_fs
*ofs
= sb
->s_fs_info
;
346 seq_show_option(m
, "lowerdir", ofs
->config
.lowerdir
);
347 if (ofs
->config
.upperdir
) {
348 seq_show_option(m
, "upperdir", ofs
->config
.upperdir
);
349 seq_show_option(m
, "workdir", ofs
->config
.workdir
);
351 if (ofs
->config
.default_permissions
)
352 seq_puts(m
, ",default_permissions");
353 if (strcmp(ofs
->config
.redirect_mode
, ovl_redirect_mode_def()) != 0)
354 seq_printf(m
, ",redirect_dir=%s", ofs
->config
.redirect_mode
);
355 if (ofs
->config
.index
!= ovl_index_def
)
356 seq_printf(m
, ",index=%s", ofs
->config
.index
? "on" : "off");
357 if (ofs
->config
.nfs_export
!= ovl_nfs_export_def
)
358 seq_printf(m
, ",nfs_export=%s", ofs
->config
.nfs_export
?
360 if (ofs
->config
.xino
!= ovl_xino_def())
361 seq_printf(m
, ",xino=%s", ovl_xino_str
[ofs
->config
.xino
]);
362 if (ofs
->config
.metacopy
!= ovl_metacopy_def
)
363 seq_printf(m
, ",metacopy=%s",
364 ofs
->config
.metacopy
? "on" : "off");
368 static int ovl_remount(struct super_block
*sb
, int *flags
, char *data
)
370 struct ovl_fs
*ofs
= sb
->s_fs_info
;
372 if (!(*flags
& SB_RDONLY
) && ovl_force_readonly(ofs
))
378 static const struct super_operations ovl_super_operations
= {
379 .alloc_inode
= ovl_alloc_inode
,
380 .free_inode
= ovl_free_inode
,
381 .destroy_inode
= ovl_destroy_inode
,
382 .drop_inode
= generic_delete_inode
,
383 .put_super
= ovl_put_super
,
384 .sync_fs
= ovl_sync_fs
,
385 .statfs
= ovl_statfs
,
386 .show_options
= ovl_show_options
,
387 .remount_fs
= ovl_remount
,
394 OPT_DEFAULT_PERMISSIONS
,
408 static const match_table_t ovl_tokens
= {
409 {OPT_LOWERDIR
, "lowerdir=%s"},
410 {OPT_UPPERDIR
, "upperdir=%s"},
411 {OPT_WORKDIR
, "workdir=%s"},
412 {OPT_DEFAULT_PERMISSIONS
, "default_permissions"},
413 {OPT_REDIRECT_DIR
, "redirect_dir=%s"},
414 {OPT_INDEX_ON
, "index=on"},
415 {OPT_INDEX_OFF
, "index=off"},
416 {OPT_NFS_EXPORT_ON
, "nfs_export=on"},
417 {OPT_NFS_EXPORT_OFF
, "nfs_export=off"},
418 {OPT_XINO_ON
, "xino=on"},
419 {OPT_XINO_OFF
, "xino=off"},
420 {OPT_XINO_AUTO
, "xino=auto"},
421 {OPT_METACOPY_ON
, "metacopy=on"},
422 {OPT_METACOPY_OFF
, "metacopy=off"},
426 static char *ovl_next_opt(char **s
)
434 for (p
= sbegin
; *p
; p
++) {
439 } else if (*p
== ',') {
449 static int ovl_parse_redirect_mode(struct ovl_config
*config
, const char *mode
)
451 if (strcmp(mode
, "on") == 0) {
452 config
->redirect_dir
= true;
454 * Does not make sense to have redirect creation without
455 * redirect following.
457 config
->redirect_follow
= true;
458 } else if (strcmp(mode
, "follow") == 0) {
459 config
->redirect_follow
= true;
460 } else if (strcmp(mode
, "off") == 0) {
461 if (ovl_redirect_always_follow
)
462 config
->redirect_follow
= true;
463 } else if (strcmp(mode
, "nofollow") != 0) {
464 pr_err("overlayfs: bad mount option \"redirect_dir=%s\"\n",
472 static int ovl_parse_opt(char *opt
, struct ovl_config
*config
)
476 bool metacopy_opt
= false, redirect_opt
= false;
478 config
->redirect_mode
= kstrdup(ovl_redirect_mode_def(), GFP_KERNEL
);
479 if (!config
->redirect_mode
)
482 while ((p
= ovl_next_opt(&opt
)) != NULL
) {
484 substring_t args
[MAX_OPT_ARGS
];
489 token
= match_token(p
, ovl_tokens
, args
);
492 kfree(config
->upperdir
);
493 config
->upperdir
= match_strdup(&args
[0]);
494 if (!config
->upperdir
)
499 kfree(config
->lowerdir
);
500 config
->lowerdir
= match_strdup(&args
[0]);
501 if (!config
->lowerdir
)
506 kfree(config
->workdir
);
507 config
->workdir
= match_strdup(&args
[0]);
508 if (!config
->workdir
)
512 case OPT_DEFAULT_PERMISSIONS
:
513 config
->default_permissions
= true;
516 case OPT_REDIRECT_DIR
:
517 kfree(config
->redirect_mode
);
518 config
->redirect_mode
= match_strdup(&args
[0]);
519 if (!config
->redirect_mode
)
525 config
->index
= true;
529 config
->index
= false;
532 case OPT_NFS_EXPORT_ON
:
533 config
->nfs_export
= true;
536 case OPT_NFS_EXPORT_OFF
:
537 config
->nfs_export
= false;
541 config
->xino
= OVL_XINO_ON
;
545 config
->xino
= OVL_XINO_OFF
;
549 config
->xino
= OVL_XINO_AUTO
;
552 case OPT_METACOPY_ON
:
553 config
->metacopy
= true;
557 case OPT_METACOPY_OFF
:
558 config
->metacopy
= false;
562 pr_err("overlayfs: unrecognized mount option \"%s\" or missing value\n", p
);
567 /* Workdir is useless in non-upper mount */
568 if (!config
->upperdir
&& config
->workdir
) {
569 pr_info("overlayfs: option \"workdir=%s\" is useless in a non-upper mount, ignore\n",
571 kfree(config
->workdir
);
572 config
->workdir
= NULL
;
575 err
= ovl_parse_redirect_mode(config
, config
->redirect_mode
);
580 * This is to make the logic below simpler. It doesn't make any other
581 * difference, since config->redirect_dir is only used for upper.
583 if (!config
->upperdir
&& config
->redirect_follow
)
584 config
->redirect_dir
= true;
586 /* Resolve metacopy -> redirect_dir dependency */
587 if (config
->metacopy
&& !config
->redirect_dir
) {
588 if (metacopy_opt
&& redirect_opt
) {
589 pr_err("overlayfs: conflicting options: metacopy=on,redirect_dir=%s\n",
590 config
->redirect_mode
);
595 * There was an explicit redirect_dir=... that resulted
598 pr_info("overlayfs: disabling metacopy due to redirect_dir=%s\n",
599 config
->redirect_mode
);
600 config
->metacopy
= false;
602 /* Automatically enable redirect otherwise. */
603 config
->redirect_follow
= config
->redirect_dir
= true;
610 #define OVL_WORKDIR_NAME "work"
611 #define OVL_INDEXDIR_NAME "index"
613 static struct dentry
*ovl_workdir_create(struct ovl_fs
*ofs
,
614 const char *name
, bool persist
)
616 struct inode
*dir
= ofs
->workbasedir
->d_inode
;
617 struct vfsmount
*mnt
= ofs
->upper_mnt
;
620 bool retried
= false;
623 inode_lock_nested(dir
, I_MUTEX_PARENT
);
627 work
= lookup_one_len(name
, ofs
->workbasedir
, strlen(name
));
630 struct iattr attr
= {
631 .ia_valid
= ATTR_MODE
,
632 .ia_mode
= S_IFDIR
| 0,
644 ovl_workdir_cleanup(dir
, mnt
, work
, 0);
649 work
= ovl_create_real(dir
, work
, OVL_CATTR(attr
.ia_mode
));
655 * Try to remove POSIX ACL xattrs from workdir. We are good if:
657 * a) success (there was a POSIX ACL xattr and was removed)
658 * b) -ENODATA (there was no POSIX ACL xattr)
659 * c) -EOPNOTSUPP (POSIX ACL xattrs are not supported)
661 * There are various other error values that could effectively
662 * mean that the xattr doesn't exist (e.g. -ERANGE is returned
663 * if the xattr name is too long), but the set of filesystems
664 * allowed as upper are limited to "normal" ones, where checking
665 * for the above two errors is sufficient.
667 err
= vfs_removexattr(work
, XATTR_NAME_POSIX_ACL_DEFAULT
);
668 if (err
&& err
!= -ENODATA
&& err
!= -EOPNOTSUPP
)
671 err
= vfs_removexattr(work
, XATTR_NAME_POSIX_ACL_ACCESS
);
672 if (err
&& err
!= -ENODATA
&& err
!= -EOPNOTSUPP
)
675 /* Clear any inherited mode bits */
676 inode_lock(work
->d_inode
);
677 err
= notify_change(work
, &attr
, NULL
);
678 inode_unlock(work
->d_inode
);
694 pr_warn("overlayfs: failed to create directory %s/%s (errno: %i); mounting read-only\n",
695 ofs
->config
.workdir
, name
, -err
);
700 static void ovl_unescape(char *s
)
713 static int ovl_mount_dir_noesc(const char *name
, struct path
*path
)
718 pr_err("overlayfs: empty lowerdir\n");
721 err
= kern_path(name
, LOOKUP_FOLLOW
, path
);
723 pr_err("overlayfs: failed to resolve '%s': %i\n", name
, err
);
727 if (ovl_dentry_weird(path
->dentry
)) {
728 pr_err("overlayfs: filesystem on '%s' not supported\n", name
);
731 if (!d_is_dir(path
->dentry
)) {
732 pr_err("overlayfs: '%s' not a directory\n", name
);
743 static int ovl_mount_dir(const char *name
, struct path
*path
)
746 char *tmp
= kstrdup(name
, GFP_KERNEL
);
750 err
= ovl_mount_dir_noesc(tmp
, path
);
753 if (ovl_dentry_remote(path
->dentry
)) {
754 pr_err("overlayfs: filesystem on '%s' not supported as upperdir\n",
764 static int ovl_check_namelen(struct path
*path
, struct ovl_fs
*ofs
,
767 struct kstatfs statfs
;
768 int err
= vfs_statfs(path
, &statfs
);
771 pr_err("overlayfs: statfs failed on '%s'\n", name
);
773 ofs
->namelen
= max(ofs
->namelen
, statfs
.f_namelen
);
778 static int ovl_lower_dir(const char *name
, struct path
*path
,
779 struct ovl_fs
*ofs
, int *stack_depth
, bool *remote
)
784 err
= ovl_mount_dir_noesc(name
, path
);
788 err
= ovl_check_namelen(path
, ofs
, name
);
792 *stack_depth
= max(*stack_depth
, path
->mnt
->mnt_sb
->s_stack_depth
);
794 if (ovl_dentry_remote(path
->dentry
))
798 * The inodes index feature and NFS export need to encode and decode
799 * file handles, so they require that all layers support them.
801 fh_type
= ovl_can_decode_fh(path
->dentry
->d_sb
);
802 if ((ofs
->config
.nfs_export
||
803 (ofs
->config
.index
&& ofs
->config
.upperdir
)) && !fh_type
) {
804 ofs
->config
.index
= false;
805 ofs
->config
.nfs_export
= false;
806 pr_warn("overlayfs: fs on '%s' does not support file handles, falling back to index=off,nfs_export=off.\n",
810 /* Check if lower fs has 32bit inode numbers */
811 if (fh_type
!= FILEID_INO32_GEN
)
822 /* Workdir should not be subdir of upperdir and vice versa */
823 static bool ovl_workdir_ok(struct dentry
*workdir
, struct dentry
*upperdir
)
827 if (workdir
!= upperdir
) {
828 ok
= (lock_rename(workdir
, upperdir
) == NULL
);
829 unlock_rename(workdir
, upperdir
);
834 static unsigned int ovl_split_lowerdirs(char *str
)
836 unsigned int ctr
= 1;
839 for (s
= d
= str
;; s
++, d
++) {
842 } else if (*s
== ':') {
854 static int __maybe_unused
855 ovl_posix_acl_xattr_get(const struct xattr_handler
*handler
,
856 struct dentry
*dentry
, struct inode
*inode
,
857 const char *name
, void *buffer
, size_t size
)
859 return ovl_xattr_get(dentry
, inode
, handler
->name
, buffer
, size
);
862 static int __maybe_unused
863 ovl_posix_acl_xattr_set(const struct xattr_handler
*handler
,
864 struct dentry
*dentry
, struct inode
*inode
,
865 const char *name
, const void *value
,
866 size_t size
, int flags
)
868 struct dentry
*workdir
= ovl_workdir(dentry
);
869 struct inode
*realinode
= ovl_inode_real(inode
);
870 struct posix_acl
*acl
= NULL
;
873 /* Check that everything is OK before copy-up */
875 acl
= posix_acl_from_xattr(&init_user_ns
, value
, size
);
880 if (!IS_POSIXACL(d_inode(workdir
)))
881 goto out_acl_release
;
882 if (!realinode
->i_op
->set_acl
)
883 goto out_acl_release
;
884 if (handler
->flags
== ACL_TYPE_DEFAULT
&& !S_ISDIR(inode
->i_mode
)) {
885 err
= acl
? -EACCES
: 0;
886 goto out_acl_release
;
889 if (!inode_owner_or_capable(inode
))
890 goto out_acl_release
;
892 posix_acl_release(acl
);
895 * Check if sgid bit needs to be cleared (actual setacl operation will
896 * be done with mounter's capabilities and so that won't do it for us).
898 if (unlikely(inode
->i_mode
& S_ISGID
) &&
899 handler
->flags
== ACL_TYPE_ACCESS
&&
900 !in_group_p(inode
->i_gid
) &&
901 !capable_wrt_inode_uidgid(inode
, CAP_FSETID
)) {
902 struct iattr iattr
= { .ia_valid
= ATTR_KILL_SGID
};
904 err
= ovl_setattr(dentry
, &iattr
);
909 err
= ovl_xattr_set(dentry
, inode
, handler
->name
, value
, size
, flags
);
911 ovl_copyattr(ovl_inode_real(inode
), inode
);
916 posix_acl_release(acl
);
920 static int ovl_own_xattr_get(const struct xattr_handler
*handler
,
921 struct dentry
*dentry
, struct inode
*inode
,
922 const char *name
, void *buffer
, size_t size
)
927 static int ovl_own_xattr_set(const struct xattr_handler
*handler
,
928 struct dentry
*dentry
, struct inode
*inode
,
929 const char *name
, const void *value
,
930 size_t size
, int flags
)
935 static int ovl_other_xattr_get(const struct xattr_handler
*handler
,
936 struct dentry
*dentry
, struct inode
*inode
,
937 const char *name
, void *buffer
, size_t size
)
939 return ovl_xattr_get(dentry
, inode
, name
, buffer
, size
);
942 static int ovl_other_xattr_set(const struct xattr_handler
*handler
,
943 struct dentry
*dentry
, struct inode
*inode
,
944 const char *name
, const void *value
,
945 size_t size
, int flags
)
947 return ovl_xattr_set(dentry
, inode
, name
, value
, size
, flags
);
950 static const struct xattr_handler __maybe_unused
951 ovl_posix_acl_access_xattr_handler
= {
952 .name
= XATTR_NAME_POSIX_ACL_ACCESS
,
953 .flags
= ACL_TYPE_ACCESS
,
954 .get
= ovl_posix_acl_xattr_get
,
955 .set
= ovl_posix_acl_xattr_set
,
958 static const struct xattr_handler __maybe_unused
959 ovl_posix_acl_default_xattr_handler
= {
960 .name
= XATTR_NAME_POSIX_ACL_DEFAULT
,
961 .flags
= ACL_TYPE_DEFAULT
,
962 .get
= ovl_posix_acl_xattr_get
,
963 .set
= ovl_posix_acl_xattr_set
,
966 static const struct xattr_handler ovl_own_xattr_handler
= {
967 .prefix
= OVL_XATTR_PREFIX
,
968 .get
= ovl_own_xattr_get
,
969 .set
= ovl_own_xattr_set
,
972 static const struct xattr_handler ovl_other_xattr_handler
= {
973 .prefix
= "", /* catch all */
974 .get
= ovl_other_xattr_get
,
975 .set
= ovl_other_xattr_set
,
978 static const struct xattr_handler
*ovl_xattr_handlers
[] = {
979 #ifdef CONFIG_FS_POSIX_ACL
980 &ovl_posix_acl_access_xattr_handler
,
981 &ovl_posix_acl_default_xattr_handler
,
983 &ovl_own_xattr_handler
,
984 &ovl_other_xattr_handler
,
988 static int ovl_setup_trap(struct super_block
*sb
, struct dentry
*dir
,
989 struct inode
**ptrap
, const char *name
)
994 trap
= ovl_get_trap_inode(sb
, dir
);
998 pr_err("overlayfs: conflicting %s path\n", name
);
1006 static int ovl_get_upper(struct super_block
*sb
, struct ovl_fs
*ofs
,
1007 struct path
*upperpath
)
1009 struct vfsmount
*upper_mnt
;
1012 err
= ovl_mount_dir(ofs
->config
.upperdir
, upperpath
);
1016 /* Upper fs should not be r/o */
1017 if (sb_rdonly(upperpath
->mnt
->mnt_sb
)) {
1018 pr_err("overlayfs: upper fs is r/o, try multi-lower layers mount\n");
1023 err
= ovl_check_namelen(upperpath
, ofs
, ofs
->config
.upperdir
);
1027 err
= ovl_setup_trap(sb
, upperpath
->dentry
, &ofs
->upperdir_trap
,
1032 upper_mnt
= clone_private_mount(upperpath
);
1033 err
= PTR_ERR(upper_mnt
);
1034 if (IS_ERR(upper_mnt
)) {
1035 pr_err("overlayfs: failed to clone upperpath\n");
1039 /* Don't inherit atime flags */
1040 upper_mnt
->mnt_flags
&= ~(MNT_NOATIME
| MNT_NODIRATIME
| MNT_RELATIME
);
1041 ofs
->upper_mnt
= upper_mnt
;
1044 if (ovl_inuse_trylock(ofs
->upper_mnt
->mnt_root
)) {
1045 ofs
->upperdir_locked
= true;
1046 } else if (ofs
->config
.index
) {
1047 pr_err("overlayfs: upperdir is in-use by another mount, mount with '-o index=off' to override exclusive upperdir protection.\n");
1050 pr_warn("overlayfs: upperdir is in-use by another mount, accessing files from both mounts will result in undefined behavior.\n");
1058 static int ovl_make_workdir(struct super_block
*sb
, struct ovl_fs
*ofs
,
1059 struct path
*workpath
)
1061 struct vfsmount
*mnt
= ofs
->upper_mnt
;
1062 struct dentry
*temp
;
1066 err
= mnt_want_write(mnt
);
1070 ofs
->workdir
= ovl_workdir_create(ofs
, OVL_WORKDIR_NAME
, false);
1074 err
= ovl_setup_trap(sb
, ofs
->workdir
, &ofs
->workdir_trap
, "workdir");
1079 * Upper should support d_type, else whiteouts are visible. Given
1080 * workdir and upper are on same fs, we can do iterate_dir() on
1081 * workdir. This check requires successful creation of workdir in
1084 err
= ovl_check_d_type_supported(workpath
);
1089 * We allowed this configuration and don't want to break users over
1090 * kernel upgrade. So warn instead of erroring out.
1093 pr_warn("overlayfs: upper fs needs to support d_type.\n");
1095 /* Check if upper/work fs supports O_TMPFILE */
1096 temp
= ovl_do_tmpfile(ofs
->workdir
, S_IFREG
| 0);
1097 ofs
->tmpfile
= !IS_ERR(temp
);
1101 pr_warn("overlayfs: upper fs does not support tmpfile.\n");
1104 * Check if upper/work fs supports trusted.overlay.* xattr
1106 err
= ovl_do_setxattr(ofs
->workdir
, OVL_XATTR_OPAQUE
, "0", 1, 0);
1108 ofs
->noxattr
= true;
1109 ofs
->config
.index
= false;
1110 ofs
->config
.metacopy
= false;
1111 pr_warn("overlayfs: upper fs does not support xattr, falling back to index=off and metacopy=off.\n");
1114 vfs_removexattr(ofs
->workdir
, OVL_XATTR_OPAQUE
);
1117 /* Check if upper/work fs supports file handles */
1118 fh_type
= ovl_can_decode_fh(ofs
->workdir
->d_sb
);
1119 if (ofs
->config
.index
&& !fh_type
) {
1120 ofs
->config
.index
= false;
1121 pr_warn("overlayfs: upper fs does not support file handles, falling back to index=off.\n");
1124 /* Check if upper fs has 32bit inode numbers */
1125 if (fh_type
!= FILEID_INO32_GEN
)
1128 /* NFS export of r/w mount depends on index */
1129 if (ofs
->config
.nfs_export
&& !ofs
->config
.index
) {
1130 pr_warn("overlayfs: NFS export requires \"index=on\", falling back to nfs_export=off.\n");
1131 ofs
->config
.nfs_export
= false;
1134 mnt_drop_write(mnt
);
1138 static int ovl_get_workdir(struct super_block
*sb
, struct ovl_fs
*ofs
,
1139 struct path
*upperpath
)
1142 struct path workpath
= { };
1144 err
= ovl_mount_dir(ofs
->config
.workdir
, &workpath
);
1149 if (upperpath
->mnt
!= workpath
.mnt
) {
1150 pr_err("overlayfs: workdir and upperdir must reside under the same mount\n");
1153 if (!ovl_workdir_ok(workpath
.dentry
, upperpath
->dentry
)) {
1154 pr_err("overlayfs: workdir and upperdir must be separate subtrees\n");
1158 ofs
->workbasedir
= dget(workpath
.dentry
);
1161 if (ovl_inuse_trylock(ofs
->workbasedir
)) {
1162 ofs
->workdir_locked
= true;
1163 } else if (ofs
->config
.index
) {
1164 pr_err("overlayfs: workdir is in-use by another mount, mount with '-o index=off' to override exclusive workdir protection.\n");
1167 pr_warn("overlayfs: workdir is in-use by another mount, accessing files from both mounts will result in undefined behavior.\n");
1170 err
= ovl_make_workdir(sb
, ofs
, &workpath
);
1173 path_put(&workpath
);
1178 static int ovl_get_indexdir(struct super_block
*sb
, struct ovl_fs
*ofs
,
1179 struct ovl_entry
*oe
, struct path
*upperpath
)
1181 struct vfsmount
*mnt
= ofs
->upper_mnt
;
1184 err
= mnt_want_write(mnt
);
1188 /* Verify lower root is upper root origin */
1189 err
= ovl_verify_origin(upperpath
->dentry
, oe
->lowerstack
[0].dentry
,
1192 pr_err("overlayfs: failed to verify upper root origin\n");
1196 ofs
->indexdir
= ovl_workdir_create(ofs
, OVL_INDEXDIR_NAME
, true);
1197 if (ofs
->indexdir
) {
1198 err
= ovl_setup_trap(sb
, ofs
->indexdir
, &ofs
->indexdir_trap
,
1204 * Verify upper root is exclusively associated with index dir.
1205 * Older kernels stored upper fh in "trusted.overlay.origin"
1206 * xattr. If that xattr exists, verify that it is a match to
1207 * upper dir file handle. In any case, verify or set xattr
1208 * "trusted.overlay.upper" to indicate that index may have
1209 * directory entries.
1211 if (ovl_check_origin_xattr(ofs
->indexdir
)) {
1212 err
= ovl_verify_set_fh(ofs
->indexdir
, OVL_XATTR_ORIGIN
,
1213 upperpath
->dentry
, true, false);
1215 pr_err("overlayfs: failed to verify index dir 'origin' xattr\n");
1217 err
= ovl_verify_upper(ofs
->indexdir
, upperpath
->dentry
, true);
1219 pr_err("overlayfs: failed to verify index dir 'upper' xattr\n");
1221 /* Cleanup bad/stale/orphan index entries */
1223 err
= ovl_indexdir_cleanup(ofs
);
1225 if (err
|| !ofs
->indexdir
)
1226 pr_warn("overlayfs: try deleting index dir or mounting with '-o index=off' to disable inodes index.\n");
1229 mnt_drop_write(mnt
);
1233 static bool ovl_lower_uuid_ok(struct ovl_fs
*ofs
, const uuid_t
*uuid
)
1237 if (!ofs
->config
.nfs_export
&& !(ofs
->config
.index
&& ofs
->upper_mnt
))
1240 for (i
= 0; i
< ofs
->numlowerfs
; i
++) {
1242 * We use uuid to associate an overlay lower file handle with a
1243 * lower layer, so we can accept lower fs with null uuid as long
1244 * as all lower layers with null uuid are on the same fs.
1246 if (uuid_equal(&ofs
->lower_fs
[i
].sb
->s_uuid
, uuid
))
1252 /* Get a unique fsid for the layer */
1253 static int ovl_get_fsid(struct ovl_fs
*ofs
, const struct path
*path
)
1255 struct super_block
*sb
= path
->mnt
->mnt_sb
;
1260 /* fsid 0 is reserved for upper fs even with non upper overlay */
1261 if (ofs
->upper_mnt
&& ofs
->upper_mnt
->mnt_sb
== sb
)
1264 for (i
= 0; i
< ofs
->numlowerfs
; i
++) {
1265 if (ofs
->lower_fs
[i
].sb
== sb
)
1269 if (!ovl_lower_uuid_ok(ofs
, &sb
->s_uuid
)) {
1270 ofs
->config
.index
= false;
1271 ofs
->config
.nfs_export
= false;
1272 pr_warn("overlayfs: %s uuid detected in lower fs '%pd2', falling back to index=off,nfs_export=off.\n",
1273 uuid_is_null(&sb
->s_uuid
) ? "null" : "conflicting",
1277 err
= get_anon_bdev(&dev
);
1279 pr_err("overlayfs: failed to get anonymous bdev for lowerpath\n");
1283 ofs
->lower_fs
[ofs
->numlowerfs
].sb
= sb
;
1284 ofs
->lower_fs
[ofs
->numlowerfs
].pseudo_dev
= dev
;
1287 return ofs
->numlowerfs
;
1290 static int ovl_get_lower_layers(struct super_block
*sb
, struct ovl_fs
*ofs
,
1291 struct path
*stack
, unsigned int numlower
)
1297 ofs
->lower_layers
= kcalloc(numlower
, sizeof(struct ovl_layer
),
1299 if (ofs
->lower_layers
== NULL
)
1302 ofs
->lower_fs
= kcalloc(numlower
, sizeof(struct ovl_sb
),
1304 if (ofs
->lower_fs
== NULL
)
1307 for (i
= 0; i
< numlower
; i
++) {
1308 struct vfsmount
*mnt
;
1312 err
= fsid
= ovl_get_fsid(ofs
, &stack
[i
]);
1317 if (ovl_is_inuse(stack
[i
].dentry
)) {
1318 pr_err("overlayfs: lowerdir is in-use as upperdir/workdir\n");
1322 err
= ovl_setup_trap(sb
, stack
[i
].dentry
, &trap
, "lowerdir");
1326 mnt
= clone_private_mount(&stack
[i
]);
1329 pr_err("overlayfs: failed to clone lowerpath\n");
1335 * Make lower layers R/O. That way fchmod/fchown on lower file
1336 * will fail instead of modifying lower fs.
1338 mnt
->mnt_flags
|= MNT_READONLY
| MNT_NOATIME
;
1340 ofs
->lower_layers
[ofs
->numlower
].trap
= trap
;
1341 ofs
->lower_layers
[ofs
->numlower
].mnt
= mnt
;
1342 ofs
->lower_layers
[ofs
->numlower
].idx
= i
+ 1;
1343 ofs
->lower_layers
[ofs
->numlower
].fsid
= fsid
;
1345 ofs
->lower_layers
[ofs
->numlower
].fs
=
1346 &ofs
->lower_fs
[fsid
- 1];
1352 * When all layers on same fs, overlay can use real inode numbers.
1353 * With mount option "xino=on", mounter declares that there are enough
1354 * free high bits in underlying fs to hold the unique fsid.
1355 * If overlayfs does encounter underlying inodes using the high xino
1356 * bits reserved for fsid, it emits a warning and uses the original
1359 if (!ofs
->numlowerfs
|| (ofs
->numlowerfs
== 1 && !ofs
->upper_mnt
)) {
1361 ofs
->config
.xino
= OVL_XINO_OFF
;
1362 } else if (ofs
->config
.xino
== OVL_XINO_ON
&& !ofs
->xino_bits
) {
1364 * This is a roundup of number of bits needed for numlowerfs+1
1365 * (i.e. ilog2(numlowerfs+1 - 1) + 1). fsid 0 is reserved for
1366 * upper fs even with non upper overlay.
1368 BUILD_BUG_ON(ilog2(OVL_MAX_STACK
) > 31);
1369 ofs
->xino_bits
= ilog2(ofs
->numlowerfs
) + 1;
1372 if (ofs
->xino_bits
) {
1373 pr_info("overlayfs: \"xino\" feature enabled using %d upper inode bits.\n",
1382 static struct ovl_entry
*ovl_get_lowerstack(struct super_block
*sb
,
1386 char *lowertmp
, *lower
;
1387 struct path
*stack
= NULL
;
1388 unsigned int stacklen
, numlower
= 0, i
;
1389 bool remote
= false;
1390 struct ovl_entry
*oe
;
1393 lowertmp
= kstrdup(ofs
->config
.lowerdir
, GFP_KERNEL
);
1398 stacklen
= ovl_split_lowerdirs(lowertmp
);
1399 if (stacklen
> OVL_MAX_STACK
) {
1400 pr_err("overlayfs: too many lower directories, limit is %d\n",
1403 } else if (!ofs
->config
.upperdir
&& stacklen
== 1) {
1404 pr_err("overlayfs: at least 2 lowerdir are needed while upperdir nonexistent\n");
1406 } else if (!ofs
->config
.upperdir
&& ofs
->config
.nfs_export
&&
1407 ofs
->config
.redirect_follow
) {
1408 pr_warn("overlayfs: NFS export requires \"redirect_dir=nofollow\" on non-upper mount, falling back to nfs_export=off.\n");
1409 ofs
->config
.nfs_export
= false;
1413 stack
= kcalloc(stacklen
, sizeof(struct path
), GFP_KERNEL
);
1419 for (numlower
= 0; numlower
< stacklen
; numlower
++) {
1420 err
= ovl_lower_dir(lower
, &stack
[numlower
], ofs
,
1421 &sb
->s_stack_depth
, &remote
);
1425 lower
= strchr(lower
, '\0') + 1;
1429 sb
->s_stack_depth
++;
1430 if (sb
->s_stack_depth
> FILESYSTEM_MAX_STACK_DEPTH
) {
1431 pr_err("overlayfs: maximum fs stacking depth exceeded\n");
1435 err
= ovl_get_lower_layers(sb
, ofs
, stack
, numlower
);
1440 oe
= ovl_alloc_entry(numlower
);
1444 for (i
= 0; i
< numlower
; i
++) {
1445 oe
->lowerstack
[i
].dentry
= dget(stack
[i
].dentry
);
1446 oe
->lowerstack
[i
].layer
= &ofs
->lower_layers
[i
];
1450 sb
->s_d_op
= &ovl_reval_dentry_operations
;
1452 sb
->s_d_op
= &ovl_dentry_operations
;
1455 for (i
= 0; i
< numlower
; i
++)
1456 path_put(&stack
[i
]);
1468 * Check if this layer root is a descendant of:
1469 * - another layer of this overlayfs instance
1470 * - upper/work dir of any overlayfs instance
1471 * - a disconnected dentry (detached root)
1473 static int ovl_check_layer(struct super_block
*sb
, struct dentry
*dentry
,
1476 struct dentry
*next
, *parent
;
1477 bool is_root
= false;
1480 if (!dentry
|| dentry
== dentry
->d_sb
->s_root
)
1483 next
= dget(dentry
);
1484 /* Walk back ancestors to fs root (inclusive) looking for traps */
1486 parent
= dget_parent(next
);
1487 is_root
= (parent
== next
);
1488 if (ovl_is_inuse(parent
)) {
1490 pr_err("overlayfs: %s path overlapping in-use upperdir/workdir\n",
1492 } else if (ovl_lookup_trap_inode(sb
, parent
)) {
1494 pr_err("overlayfs: overlapping %s path\n", name
);
1498 } while (!err
&& !is_root
);
1500 /* Did we really walk to fs root or found a detached root? */
1501 if (!err
&& next
!= dentry
->d_sb
->s_root
) {
1503 pr_err("overlayfs: disconnected %s path\n", name
);
1512 * Check if any of the layers or work dirs overlap.
1514 static int ovl_check_overlapping_layers(struct super_block
*sb
,
1519 if (ofs
->upper_mnt
) {
1520 err
= ovl_check_layer(sb
, ofs
->upper_mnt
->mnt_root
, "upperdir");
1525 * Checking workbasedir avoids hitting ovl_is_inuse(parent) of
1526 * this instance and covers overlapping work and index dirs,
1527 * unless work or index dir have been moved since created inside
1528 * workbasedir. In that case, we already have their traps in
1529 * inode cache and we will catch that case on lookup.
1531 err
= ovl_check_layer(sb
, ofs
->workbasedir
, "workdir");
1536 for (i
= 0; i
< ofs
->numlower
; i
++) {
1537 err
= ovl_check_layer(sb
, ofs
->lower_layers
[i
].mnt
->mnt_root
,
1546 static int ovl_fill_super(struct super_block
*sb
, void *data
, int silent
)
1548 struct path upperpath
= { };
1549 struct dentry
*root_dentry
;
1550 struct ovl_entry
*oe
;
1556 ofs
= kzalloc(sizeof(struct ovl_fs
), GFP_KERNEL
);
1560 ofs
->creator_cred
= cred
= prepare_creds();
1564 ofs
->config
.index
= ovl_index_def
;
1565 ofs
->config
.nfs_export
= ovl_nfs_export_def
;
1566 ofs
->config
.xino
= ovl_xino_def();
1567 ofs
->config
.metacopy
= ovl_metacopy_def
;
1568 err
= ovl_parse_opt((char *) data
, &ofs
->config
);
1573 if (!ofs
->config
.lowerdir
) {
1575 pr_err("overlayfs: missing 'lowerdir'\n");
1579 sb
->s_stack_depth
= 0;
1580 sb
->s_maxbytes
= MAX_LFS_FILESIZE
;
1581 /* Assume underlaying fs uses 32bit inodes unless proven otherwise */
1582 if (ofs
->config
.xino
!= OVL_XINO_OFF
)
1583 ofs
->xino_bits
= BITS_PER_LONG
- 32;
1585 /* alloc/destroy_inode needed for setting up traps in inode cache */
1586 sb
->s_op
= &ovl_super_operations
;
1588 if (ofs
->config
.upperdir
) {
1589 if (!ofs
->config
.workdir
) {
1590 pr_err("overlayfs: missing 'workdir'\n");
1594 err
= ovl_get_upper(sb
, ofs
, &upperpath
);
1598 err
= ovl_get_workdir(sb
, ofs
, &upperpath
);
1603 sb
->s_flags
|= SB_RDONLY
;
1605 sb
->s_stack_depth
= ofs
->upper_mnt
->mnt_sb
->s_stack_depth
;
1606 sb
->s_time_gran
= ofs
->upper_mnt
->mnt_sb
->s_time_gran
;
1609 oe
= ovl_get_lowerstack(sb
, ofs
);
1614 /* If the upper fs is nonexistent, we mark overlayfs r/o too */
1615 if (!ofs
->upper_mnt
)
1616 sb
->s_flags
|= SB_RDONLY
;
1618 if (!(ovl_force_readonly(ofs
)) && ofs
->config
.index
) {
1619 err
= ovl_get_indexdir(sb
, ofs
, oe
, &upperpath
);
1623 /* Force r/o mount with no index dir */
1624 if (!ofs
->indexdir
) {
1626 ofs
->workdir
= NULL
;
1627 sb
->s_flags
|= SB_RDONLY
;
1632 err
= ovl_check_overlapping_layers(sb
, ofs
);
1636 /* Show index=off in /proc/mounts for forced r/o mount */
1637 if (!ofs
->indexdir
) {
1638 ofs
->config
.index
= false;
1639 if (ofs
->upper_mnt
&& ofs
->config
.nfs_export
) {
1640 pr_warn("overlayfs: NFS export requires an index dir, falling back to nfs_export=off.\n");
1641 ofs
->config
.nfs_export
= false;
1645 if (ofs
->config
.metacopy
&& ofs
->config
.nfs_export
) {
1646 pr_warn("overlayfs: NFS export is not supported with metadata only copy up, falling back to nfs_export=off.\n");
1647 ofs
->config
.nfs_export
= false;
1650 if (ofs
->config
.nfs_export
)
1651 sb
->s_export_op
= &ovl_export_operations
;
1653 /* Never override disk quota limits or use reserved space */
1654 cap_lower(cred
->cap_effective
, CAP_SYS_RESOURCE
);
1656 sb
->s_magic
= OVERLAYFS_SUPER_MAGIC
;
1657 sb
->s_xattr
= ovl_xattr_handlers
;
1658 sb
->s_fs_info
= ofs
;
1659 sb
->s_flags
|= SB_POSIXACL
;
1662 root_dentry
= d_make_root(ovl_new_inode(sb
, S_IFDIR
, 0));
1666 root_dentry
->d_fsdata
= oe
;
1668 mntput(upperpath
.mnt
);
1669 if (upperpath
.dentry
) {
1670 ovl_dentry_set_upper_alias(root_dentry
);
1671 if (ovl_is_impuredir(upperpath
.dentry
))
1672 ovl_set_flag(OVL_IMPURE
, d_inode(root_dentry
));
1675 /* Root is always merge -> can have whiteouts */
1676 ovl_set_flag(OVL_WHITEOUTS
, d_inode(root_dentry
));
1677 ovl_dentry_set_flag(OVL_E_CONNECTED
, root_dentry
);
1678 ovl_set_upperdata(d_inode(root_dentry
));
1679 ovl_inode_init(d_inode(root_dentry
), upperpath
.dentry
,
1680 ovl_dentry_lower(root_dentry
), NULL
);
1682 sb
->s_root
= root_dentry
;
1687 ovl_entry_stack_free(oe
);
1690 path_put(&upperpath
);
1696 static struct dentry
*ovl_mount(struct file_system_type
*fs_type
, int flags
,
1697 const char *dev_name
, void *raw_data
)
1699 return mount_nodev(fs_type
, flags
, raw_data
, ovl_fill_super
);
1702 static struct file_system_type ovl_fs_type
= {
1703 .owner
= THIS_MODULE
,
1706 .kill_sb
= kill_anon_super
,
1708 MODULE_ALIAS_FS("overlay");
1710 static void ovl_inode_init_once(void *foo
)
1712 struct ovl_inode
*oi
= foo
;
1714 inode_init_once(&oi
->vfs_inode
);
1717 static int __init
ovl_init(void)
1721 ovl_inode_cachep
= kmem_cache_create("ovl_inode",
1722 sizeof(struct ovl_inode
), 0,
1723 (SLAB_RECLAIM_ACCOUNT
|
1724 SLAB_MEM_SPREAD
|SLAB_ACCOUNT
),
1725 ovl_inode_init_once
);
1726 if (ovl_inode_cachep
== NULL
)
1729 err
= register_filesystem(&ovl_fs_type
);
1731 kmem_cache_destroy(ovl_inode_cachep
);
1736 static void __exit
ovl_exit(void)
1738 unregister_filesystem(&ovl_fs_type
);
1741 * Make sure all delayed rcu free inodes are flushed before we
1745 kmem_cache_destroy(ovl_inode_cachep
);
1749 module_init(ovl_init
);
1750 module_exit(ovl_exit
);