Lines Matching refs:ofs
220 static void ovl_free_fs(struct ovl_fs *ofs)
225 iput(ofs->workbasedir_trap);
226 iput(ofs->indexdir_trap);
227 iput(ofs->workdir_trap);
228 dput(ofs->whiteout);
229 dput(ofs->indexdir);
230 dput(ofs->workdir);
231 if (ofs->workdir_locked)
232 ovl_inuse_unlock(ofs->workbasedir);
233 dput(ofs->workbasedir);
234 if (ofs->upperdir_locked)
235 ovl_inuse_unlock(ovl_upper_mnt(ofs)->mnt_root);
237 /* Hack! Reuse ofs->layers as a vfsmount array before freeing it */
238 mounts = (struct vfsmount **) ofs->layers;
239 for (i = 0; i < ofs->numlayer; i++) {
240 iput(ofs->layers[i].trap);
241 mounts[i] = ofs->layers[i].mnt;
243 kern_unmount_array(mounts, ofs->numlayer);
244 kfree(ofs->layers);
245 for (i = 0; i < ofs->numfs; i++)
246 free_anon_bdev(ofs->fs[i].pseudo_dev);
247 kfree(ofs->fs);
249 kfree(ofs->config.lowerdir);
250 kfree(ofs->config.upperdir);
251 kfree(ofs->config.workdir);
252 kfree(ofs->config.redirect_mode);
253 if (ofs->creator_cred)
254 put_cred(ofs->creator_cred);
255 kfree(ofs);
260 struct ovl_fs *ofs = sb->s_fs_info;
262 ovl_free_fs(ofs);
268 struct ovl_fs *ofs = sb->s_fs_info;
272 ret = ovl_sync_status(ofs);
297 upper_sb = ovl_upper_mnt(ofs)->mnt_sb;
316 struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
325 buf->f_namelen = ofs->namelen;
333 static bool ovl_force_readonly(struct ovl_fs *ofs)
335 return (!ovl_upper_mnt(ofs) || !ofs->workdir);
363 struct ovl_fs *ofs = sb->s_fs_info;
365 seq_show_option(m, "lowerdir", ofs->config.lowerdir);
366 if (ofs->config.upperdir) {
367 seq_show_option(m, "upperdir", ofs->config.upperdir);
368 seq_show_option(m, "workdir", ofs->config.workdir);
370 if (ofs->config.default_permissions)
372 if (strcmp(ofs->config.redirect_mode, ovl_redirect_mode_def()) != 0)
373 seq_printf(m, ",redirect_dir=%s", ofs->config.redirect_mode);
374 if (ofs->config.index != ovl_index_def)
375 seq_printf(m, ",index=%s", ofs->config.index ? "on" : "off");
376 if (ofs->config.nfs_export != ovl_nfs_export_def)
377 seq_printf(m, ",nfs_export=%s", ofs->config.nfs_export ?
379 if (ofs->config.xino != ovl_xino_def() && !ovl_same_fs(sb))
380 seq_printf(m, ",xino=%s", ovl_xino_str[ofs->config.xino]);
381 if (ofs->config.metacopy != ovl_metacopy_def)
383 ofs->config.metacopy ? "on" : "off");
384 if (ofs->config.ovl_volatile)
391 struct ovl_fs *ofs = sb->s_fs_info;
395 if (!(*flags & SB_RDONLY) && ovl_force_readonly(ofs))
399 upper_sb = ovl_upper_mnt(ofs)->mnt_sb;
400 if (ovl_should_sync(ofs)) {
714 static struct dentry *ovl_workdir_create(struct ovl_fs *ofs,
717 struct inode *dir = ofs->workbasedir->d_inode;
718 struct vfsmount *mnt = ovl_upper_mnt(ofs);
725 work = lookup_one_len(name, ofs->workbasedir, strlen(name));
799 ofs->config.workdir, name, -err);
867 static int ovl_check_namelen(struct path *path, struct ovl_fs *ofs,
876 ofs->namelen = max(ofs->namelen, statfs.f_namelen);
882 struct ovl_fs *ofs, int *stack_depth)
891 err = ovl_check_namelen(path, ofs, name);
902 if ((ofs->config.nfs_export ||
903 (ofs->config.index && ofs->config.upperdir)) && !fh_type) {
904 ofs->config.index = false;
905 ofs->config.nfs_export = false;
912 ofs->xino_mode = -1;
1107 static int ovl_report_in_use(struct ovl_fs *ofs, const char *name)
1109 if (ofs->config.index) {
1120 static int ovl_get_upper(struct super_block *sb, struct ovl_fs *ofs,
1126 err = ovl_mount_dir(ofs->config.upperdir, upperpath);
1137 err = ovl_check_namelen(upperpath, ofs, ofs->config.upperdir);
1171 if (ovl_inuse_trylock(ovl_upper_mnt(ofs)->mnt_root)) {
1172 ofs->upperdir_locked = true;
1174 err = ovl_report_in_use(ofs, "upperdir");
1265 static int ovl_create_volatile_dirty(struct ovl_fs *ofs)
1268 struct dentry *d = dget(ofs->workbasedir);
1283 static int ovl_make_workdir(struct super_block *sb, struct ovl_fs *ofs,
1286 struct vfsmount *mnt = ovl_upper_mnt(ofs);
1297 workdir = ovl_workdir_create(ofs, OVL_WORKDIR_NAME, false);
1302 ofs->workdir = workdir;
1304 err = ovl_setup_trap(sb, ofs->workdir, &ofs->workdir_trap, "workdir");
1323 temp = ovl_do_tmpfile(ofs->workdir, S_IFREG | 0);
1324 ofs->tmpfile = !IS_ERR(temp);
1325 if (ofs->tmpfile)
1332 err = ovl_check_rename_whiteout(ofs->workdir);
1343 err = ovl_do_setxattr(ofs, ofs->workdir, OVL_XATTR_OPAQUE, "0", 1);
1345 ofs->noxattr = true;
1346 ofs->config.index = false;
1347 ofs->config.metacopy = false;
1351 ovl_do_removexattr(ofs, ofs->workdir, OVL_XATTR_OPAQUE);
1359 if (ovl_dentry_remote(ofs->workdir) &&
1360 (!d_type || !rename_whiteout || ofs->noxattr)) {
1370 if (ofs->config.ovl_volatile) {
1371 err = ovl_create_volatile_dirty(ofs);
1379 fh_type = ovl_can_decode_fh(ofs->workdir->d_sb);
1380 if (ofs->config.index && !fh_type) {
1381 ofs->config.index = false;
1387 ofs->xino_mode = -1;
1390 if (ofs->config.nfs_export && !ofs->config.index) {
1392 ofs->config.nfs_export = false;
1399 static int ovl_get_workdir(struct super_block *sb, struct ovl_fs *ofs,
1405 err = ovl_mount_dir(ofs->config.workdir, &workpath);
1419 ofs->workbasedir = dget(workpath.dentry);
1421 if (ovl_inuse_trylock(ofs->workbasedir)) {
1422 ofs->workdir_locked = true;
1424 err = ovl_report_in_use(ofs, "workdir");
1429 err = ovl_setup_trap(sb, ofs->workbasedir, &ofs->workbasedir_trap,
1434 err = ovl_make_workdir(sb, ofs, &workpath);
1442 static int ovl_get_indexdir(struct super_block *sb, struct ovl_fs *ofs,
1445 struct vfsmount *mnt = ovl_upper_mnt(ofs);
1454 err = ovl_verify_origin(ofs, upperpath->dentry,
1462 iput(ofs->workdir_trap);
1463 ofs->workdir_trap = NULL;
1464 dput(ofs->workdir);
1465 ofs->workdir = NULL;
1466 indexdir = ovl_workdir_create(ofs, OVL_INDEXDIR_NAME, true);
1470 ofs->indexdir = indexdir;
1471 ofs->workdir = dget(indexdir);
1473 err = ovl_setup_trap(sb, ofs->indexdir, &ofs->indexdir_trap,
1486 if (ovl_check_origin_xattr(ofs, ofs->indexdir)) {
1487 err = ovl_verify_set_fh(ofs, ofs->indexdir,
1493 err = ovl_verify_upper(ofs, ofs->indexdir, upperpath->dentry,
1500 err = ovl_indexdir_cleanup(ofs);
1502 if (err || !ofs->indexdir)
1510 static bool ovl_lower_uuid_ok(struct ovl_fs *ofs, const uuid_t *uuid)
1514 if (!ofs->config.nfs_export && !ovl_upper_mnt(ofs))
1525 if (!ofs->config.index && !ofs->config.metacopy && !ofs->config.xino &&
1529 for (i = 0; i < ofs->numfs; i++) {
1537 if (ofs->fs[i].is_lower &&
1538 uuid_equal(&ofs->fs[i].sb->s_uuid, uuid)) {
1539 ofs->fs[i].bad_uuid = true;
1547 static int ovl_get_fsid(struct ovl_fs *ofs, const struct path *path)
1555 for (i = 0; i < ofs->numfs; i++) {
1556 if (ofs->fs[i].sb == sb)
1560 if (!ovl_lower_uuid_ok(ofs, &sb->s_uuid)) {
1562 if (ofs->config.index || ofs->config.nfs_export) {
1563 ofs->config.index = false;
1564 ofs->config.nfs_export = false;
1578 ofs->fs[ofs->numfs].sb = sb;
1579 ofs->fs[ofs->numfs].pseudo_dev = dev;
1580 ofs->fs[ofs->numfs].bad_uuid = bad_uuid;
1582 return ofs->numfs++;
1585 static int ovl_get_layers(struct super_block *sb, struct ovl_fs *ofs,
1593 ofs->fs = kcalloc(numlower + 1, sizeof(struct ovl_sb), GFP_KERNEL);
1594 if (ofs->fs == NULL)
1598 ofs->numfs++;
1606 err = get_anon_bdev(&ofs->fs[0].pseudo_dev);
1612 if (ovl_upper_mnt(ofs)) {
1613 ofs->fs[0].sb = ovl_upper_mnt(ofs)->mnt_sb;
1614 ofs->fs[0].is_lower = false;
1622 err = fsid = ovl_get_fsid(ofs, &stack[i]);
1638 err = ovl_report_in_use(ofs, "lowerdir");
1659 layers[ofs->numlayer].trap = trap;
1660 layers[ofs->numlayer].mnt = mnt;
1661 layers[ofs->numlayer].idx = ofs->numlayer;
1662 layers[ofs->numlayer].fsid = fsid;
1663 layers[ofs->numlayer].fs = &ofs->fs[fsid];
1664 ofs->numlayer++;
1665 ofs->fs[fsid].is_lower = true;
1677 if (ofs->numfs - !ovl_upper_mnt(ofs) == 1) {
1678 if (ofs->config.xino == OVL_XINO_ON)
1680 ofs->xino_mode = 0;
1681 } else if (ofs->config.xino == OVL_XINO_OFF) {
1682 ofs->xino_mode = -1;
1683 } else if (ofs->xino_mode < 0) {
1692 ofs->xino_mode = ilog2(ofs->numfs - 1) + 2;
1695 if (ofs->xino_mode > 0) {
1697 ofs->xino_mode);
1707 struct ovl_fs *ofs, struct ovl_layer *layers)
1714 if (!ofs->config.upperdir && numlower == 1) {
1725 err = ovl_lower_dir(lower, &stack[i], ofs, &sb->s_stack_depth);
1739 err = ovl_get_layers(sb, ofs, stack, numlower, layers);
1750 oe->lowerstack[i].layer = &ofs->layers[i+1];
1770 static int ovl_check_layer(struct super_block *sb, struct ovl_fs *ofs,
1788 err = ovl_report_in_use(ofs, name);
1804 struct ovl_fs *ofs)
1808 if (ovl_upper_mnt(ofs)) {
1809 err = ovl_check_layer(sb, ofs, ovl_upper_mnt(ofs)->mnt_root,
1821 err = ovl_check_layer(sb, ofs, ofs->workbasedir, "workdir",
1827 for (i = 1; i < ofs->numlayer; i++) {
1828 err = ovl_check_layer(sb, ofs,
1829 ofs->layers[i].mnt->mnt_root,
1881 struct ovl_fs *ofs;
1891 ofs = kzalloc(sizeof(struct ovl_fs), GFP_KERNEL);
1892 if (!ofs)
1895 ofs->creator_cred = cred = prepare_creds();
1900 ofs->share_whiteout = true;
1902 ofs->config.index = ovl_index_def;
1903 ofs->config.nfs_export = ovl_nfs_export_def;
1904 ofs->config.xino = ovl_xino_def();
1905 ofs->config.metacopy = ovl_metacopy_def;
1906 err = ovl_parse_opt((char *) data, &ofs->config);
1911 if (!ofs->config.lowerdir) {
1918 splitlower = kstrdup(ofs->config.lowerdir, GFP_KERNEL);
1933 ofs->layers = layers;
1935 ofs->numlayer = 1;
1939 atomic_long_set(&ofs->last_ino, 1);
1941 if (ofs->config.xino != OVL_XINO_OFF) {
1942 ofs->xino_mode = BITS_PER_LONG - 32;
1943 if (!ofs->xino_mode) {
1945 ofs->config.xino = OVL_XINO_OFF;
1952 if (ofs->config.upperdir) {
1955 if (!ofs->config.workdir) {
1960 err = ovl_get_upper(sb, ofs, &layers[0], &upperpath);
1964 upper_sb = ovl_upper_mnt(ofs)->mnt_sb;
1965 if (!ovl_should_sync(ofs)) {
1966 ofs->errseq = errseq_sample(&upper_sb->s_wb_err);
1967 if (errseq_check(&upper_sb->s_wb_err, ofs->errseq)) {
1974 err = ovl_get_workdir(sb, ofs, &upperpath);
1978 if (!ofs->workdir)
1984 oe = ovl_get_lowerstack(sb, splitlower, numlower, ofs, layers);
1990 if (!ovl_upper_mnt(ofs))
1993 if (!ovl_force_readonly(ofs) && ofs->config.index) {
1994 err = ovl_get_indexdir(sb, ofs, oe, &upperpath);
1999 if (!ofs->indexdir)
2003 err = ovl_check_overlapping_layers(sb, ofs);
2008 if (!ofs->indexdir) {
2009 ofs->config.index = false;
2010 if (ovl_upper_mnt(ofs) && ofs->config.nfs_export) {
2012 ofs->config.nfs_export = false;
2016 if (ofs->config.metacopy && ofs->config.nfs_export) {
2018 ofs->config.nfs_export = false;
2021 if (ofs->config.nfs_export)
2029 sb->s_fs_info = ofs;
2051 ovl_free_fs(ofs);