~ubuntu-branches/ubuntu/precise/linux-lowlatency/precise

« back to all changes in this revision

Viewing changes to fs/overlayfs/super.c

  • Committer: Package Import Robot
  • Author(s): Alessio Igor Bogani
  • Date: 2011-10-26 11:13:05 UTC
  • Revision ID: package-import@ubuntu.com-20111026111305-04kado7d1u2er2rl
Tags: 3.2.0-16.25
Add new lowlatency kernel flavour

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *
 
3
 * Copyright (C) 2011 Novell Inc.
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or modify it
 
6
 * under the terms of the GNU General Public License version 2 as published by
 
7
 * the Free Software Foundation.
 
8
 */
 
9
 
 
10
#include <linux/fs.h>
 
11
#include <linux/namei.h>
 
12
#include <linux/xattr.h>
 
13
#include <linux/security.h>
 
14
#include <linux/mount.h>
 
15
#include <linux/slab.h>
 
16
#include <linux/parser.h>
 
17
#include <linux/module.h>
 
18
#include <linux/seq_file.h>
 
19
#include "overlayfs.h"
 
20
 
 
21
MODULE_AUTHOR("Miklos Szeredi <miklos@szeredi.hu>");
 
22
MODULE_DESCRIPTION("Overlay filesystem");
 
23
MODULE_LICENSE("GPL");
 
24
 
 
25
struct ovl_config {
 
26
        char *lowerdir;
 
27
        char *upperdir;
 
28
};
 
29
 
 
30
/* private information held for overlayfs's superblock */
 
31
struct ovl_fs {
 
32
        struct vfsmount *upper_mnt;
 
33
        struct vfsmount *lower_mnt;
 
34
        /* pathnames of lower and upper dirs, for show_options */
 
35
        struct ovl_config config;
 
36
};
 
37
 
 
38
/* private information held for every overlayfs dentry */
 
39
struct ovl_entry {
 
40
        /*
 
41
         * Keep "double reference" on upper dentries, so that
 
42
         * d_delete() doesn't think it's OK to reset d_inode to NULL.
 
43
         */
 
44
        struct dentry *__upperdentry;
 
45
        struct dentry *lowerdentry;
 
46
        union {
 
47
                struct {
 
48
                        u64 version;
 
49
                        bool opaque;
 
50
                };
 
51
                struct rcu_head rcu;
 
52
        };
 
53
};
 
54
 
 
55
const char *ovl_whiteout_xattr = "trusted.overlay.whiteout";
 
56
const char *ovl_opaque_xattr = "trusted.overlay.opaque";
 
57
 
 
58
 
 
59
enum ovl_path_type ovl_path_type(struct dentry *dentry)
 
60
{
 
61
        struct ovl_entry *oe = dentry->d_fsdata;
 
62
 
 
63
        if (oe->__upperdentry) {
 
64
                if (oe->lowerdentry && S_ISDIR(dentry->d_inode->i_mode))
 
65
                        return OVL_PATH_MERGE;
 
66
                else
 
67
                        return OVL_PATH_UPPER;
 
68
        } else {
 
69
                return OVL_PATH_LOWER;
 
70
        }
 
71
}
 
72
 
 
73
static struct dentry *ovl_upperdentry_dereference(struct ovl_entry *oe)
 
74
{
 
75
        struct dentry *upperdentry = ACCESS_ONCE(oe->__upperdentry);
 
76
        smp_read_barrier_depends();
 
77
        return upperdentry;
 
78
}
 
79
 
 
80
void ovl_path_upper(struct dentry *dentry, struct path *path)
 
81
{
 
82
        struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
 
83
        struct ovl_entry *oe = dentry->d_fsdata;
 
84
 
 
85
        path->mnt = ofs->upper_mnt;
 
86
        path->dentry = ovl_upperdentry_dereference(oe);
 
87
}
 
88
 
 
89
void ovl_path_lower(struct dentry *dentry, struct path *path)
 
90
{
 
91
        struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
 
92
        struct ovl_entry *oe = dentry->d_fsdata;
 
93
 
 
94
        path->mnt = ofs->lower_mnt;
 
95
        path->dentry = oe->lowerdentry;
 
96
}
 
97
 
 
98
enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path)
 
99
{
 
100
 
 
101
        enum ovl_path_type type = ovl_path_type(dentry);
 
102
 
 
103
        if (type == OVL_PATH_LOWER)
 
104
                ovl_path_lower(dentry, path);
 
105
        else
 
106
                ovl_path_upper(dentry, path);
 
107
 
 
108
        return type;
 
109
}
 
110
 
 
111
struct dentry *ovl_dentry_upper(struct dentry *dentry)
 
112
{
 
113
        struct ovl_entry *oe = dentry->d_fsdata;
 
114
 
 
115
        return ovl_upperdentry_dereference(oe);
 
116
}
 
117
 
 
118
struct dentry *ovl_dentry_lower(struct dentry *dentry)
 
119
{
 
120
        struct ovl_entry *oe = dentry->d_fsdata;
 
121
 
 
122
        return oe->lowerdentry;
 
123
}
 
124
 
 
125
struct dentry *ovl_dentry_real(struct dentry *dentry)
 
126
{
 
127
        struct ovl_entry *oe = dentry->d_fsdata;
 
128
        struct dentry *realdentry;
 
129
 
 
130
        realdentry = ovl_upperdentry_dereference(oe);
 
131
        if (!realdentry)
 
132
                realdentry = oe->lowerdentry;
 
133
 
 
134
        return realdentry;
 
135
}
 
136
 
 
137
struct dentry *ovl_entry_real(struct ovl_entry *oe, bool *is_upper)
 
138
{
 
139
        struct dentry *realdentry;
 
140
 
 
141
        realdentry = ovl_upperdentry_dereference(oe);
 
142
        if (realdentry) {
 
143
                *is_upper = true;
 
144
        } else {
 
145
                realdentry = oe->lowerdentry;
 
146
                *is_upper = false;
 
147
        }
 
148
        return realdentry;
 
149
}
 
150
 
 
151
bool ovl_dentry_is_opaque(struct dentry *dentry)
 
152
{
 
153
        struct ovl_entry *oe = dentry->d_fsdata;
 
154
        return oe->opaque;
 
155
}
 
156
 
 
157
void ovl_dentry_set_opaque(struct dentry *dentry, bool opaque)
 
158
{
 
159
        struct ovl_entry *oe = dentry->d_fsdata;
 
160
        oe->opaque = opaque;
 
161
}
 
162
 
 
163
void ovl_dentry_update(struct dentry *dentry, struct dentry *upperdentry)
 
164
{
 
165
        struct ovl_entry *oe = dentry->d_fsdata;
 
166
 
 
167
        WARN_ON(!mutex_is_locked(&upperdentry->d_parent->d_inode->i_mutex));
 
168
        WARN_ON(oe->__upperdentry);
 
169
        BUG_ON(!upperdentry->d_inode);
 
170
        smp_wmb();
 
171
        oe->__upperdentry = dget(upperdentry);
 
172
}
 
173
 
 
174
void ovl_dentry_version_inc(struct dentry *dentry)
 
175
{
 
176
        struct ovl_entry *oe = dentry->d_fsdata;
 
177
 
 
178
        WARN_ON(!mutex_is_locked(&dentry->d_inode->i_mutex));
 
179
        oe->version++;
 
180
}
 
181
 
 
182
u64 ovl_dentry_version_get(struct dentry *dentry)
 
183
{
 
184
        struct ovl_entry *oe = dentry->d_fsdata;
 
185
 
 
186
        WARN_ON(!mutex_is_locked(&dentry->d_inode->i_mutex));
 
187
        return oe->version;
 
188
}
 
189
 
 
190
bool ovl_is_whiteout(struct dentry *dentry)
 
191
{
 
192
        int res;
 
193
        char val;
 
194
 
 
195
        if (!dentry)
 
196
                return false;
 
197
        if (!dentry->d_inode)
 
198
                return false;
 
199
        if (!S_ISLNK(dentry->d_inode->i_mode))
 
200
                return false;
 
201
 
 
202
        res = vfs_getxattr(dentry, ovl_whiteout_xattr, &val, 1);
 
203
        if (res == 1 && val == 'y')
 
204
                return true;
 
205
 
 
206
        return false;
 
207
}
 
208
 
 
209
static bool ovl_is_opaquedir(struct dentry *dentry)
 
210
{
 
211
        int res;
 
212
        char val;
 
213
 
 
214
        if (!S_ISDIR(dentry->d_inode->i_mode))
 
215
                return false;
 
216
 
 
217
        res = vfs_getxattr(dentry, ovl_opaque_xattr, &val, 1);
 
218
        if (res == 1 && val == 'y')
 
219
                return true;
 
220
 
 
221
        return false;
 
222
}
 
223
 
 
224
static void ovl_entry_free(struct rcu_head *head)
 
225
{
 
226
        struct ovl_entry *oe = container_of(head, struct ovl_entry, rcu);
 
227
        kfree(oe);
 
228
}
 
229
 
 
230
static void ovl_dentry_release(struct dentry *dentry)
 
231
{
 
232
        struct ovl_entry *oe = dentry->d_fsdata;
 
233
 
 
234
        if (oe) {
 
235
                dput(oe->__upperdentry);
 
236
                dput(oe->__upperdentry);
 
237
                dput(oe->lowerdentry);
 
238
                call_rcu(&oe->rcu, ovl_entry_free);
 
239
        }
 
240
}
 
241
 
 
242
const struct dentry_operations ovl_dentry_operations = {
 
243
        .d_release = ovl_dentry_release,
 
244
};
 
245
 
 
246
static struct ovl_entry *ovl_alloc_entry(void)
 
247
{
 
248
        return kzalloc(sizeof(struct ovl_entry), GFP_KERNEL);
 
249
}
 
250
 
 
251
static inline struct dentry *ovl_lookup_real(struct dentry *dir,
 
252
                                             struct qstr *name)
 
253
{
 
254
        struct dentry *dentry;
 
255
 
 
256
        mutex_lock(&dir->d_inode->i_mutex);
 
257
        dentry = lookup_one_len(name->name, dir, name->len);
 
258
        mutex_unlock(&dir->d_inode->i_mutex);
 
259
 
 
260
        if (IS_ERR(dentry)) {
 
261
                if (PTR_ERR(dentry) == -ENOENT)
 
262
                        dentry = NULL;
 
263
        } else if (!dentry->d_inode) {
 
264
                dput(dentry);
 
265
                dentry = NULL;
 
266
        }
 
267
        return dentry;
 
268
}
 
269
 
 
270
static int ovl_do_lookup(struct dentry *dentry)
 
271
{
 
272
        struct ovl_entry *oe;
 
273
        struct dentry *upperdir;
 
274
        struct dentry *lowerdir;
 
275
        struct dentry *upperdentry = NULL;
 
276
        struct dentry *lowerdentry = NULL;
 
277
        struct inode *inode = NULL;
 
278
        int err;
 
279
 
 
280
        err = -ENOMEM;
 
281
        oe = ovl_alloc_entry();
 
282
        if (!oe)
 
283
                goto out;
 
284
 
 
285
        upperdir = ovl_dentry_upper(dentry->d_parent);
 
286
        lowerdir = ovl_dentry_lower(dentry->d_parent);
 
287
 
 
288
        if (upperdir) {
 
289
                upperdentry = ovl_lookup_real(upperdir, &dentry->d_name);
 
290
                err = PTR_ERR(upperdentry);
 
291
                if (IS_ERR(upperdentry))
 
292
                        goto out_put_dir;
 
293
 
 
294
                if (lowerdir && upperdentry &&
 
295
                    (S_ISLNK(upperdentry->d_inode->i_mode) ||
 
296
                     S_ISDIR(upperdentry->d_inode->i_mode))) {
 
297
                        const struct cred *old_cred;
 
298
                        struct cred *override_cred;
 
299
 
 
300
                        err = -ENOMEM;
 
301
                        override_cred = prepare_creds();
 
302
                        if (!override_cred)
 
303
                                goto out_dput_upper;
 
304
 
 
305
                        /* CAP_SYS_ADMIN needed for getxattr */
 
306
                        cap_raise(override_cred->cap_effective, CAP_SYS_ADMIN);
 
307
                        old_cred = override_creds(override_cred);
 
308
 
 
309
                        if (ovl_is_opaquedir(upperdentry)) {
 
310
                                oe->opaque = true;
 
311
                        } else if (ovl_is_whiteout(upperdentry)) {
 
312
                                dput(upperdentry);
 
313
                                upperdentry = NULL;
 
314
                                oe->opaque = true;
 
315
                        }
 
316
                        revert_creds(old_cred);
 
317
                        put_cred(override_cred);
 
318
                }
 
319
        }
 
320
        if (lowerdir && !oe->opaque) {
 
321
                lowerdentry = ovl_lookup_real(lowerdir, &dentry->d_name);
 
322
                err = PTR_ERR(lowerdentry);
 
323
                if (IS_ERR(lowerdentry))
 
324
                        goto out_dput_upper;
 
325
        }
 
326
 
 
327
        if (lowerdentry && upperdentry &&
 
328
            (!S_ISDIR(upperdentry->d_inode->i_mode) ||
 
329
             !S_ISDIR(lowerdentry->d_inode->i_mode))) {
 
330
                dput(lowerdentry);
 
331
                lowerdentry = NULL;
 
332
                oe->opaque = true;
 
333
        }
 
334
 
 
335
        if (lowerdentry || upperdentry) {
 
336
                struct dentry *realdentry;
 
337
 
 
338
                realdentry = upperdentry ? upperdentry : lowerdentry;
 
339
                err = -ENOMEM;
 
340
                inode = ovl_new_inode(dentry->d_sb, realdentry->d_inode->i_mode,
 
341
                                      oe);
 
342
                if (!inode)
 
343
                        goto out_dput;
 
344
        }
 
345
 
 
346
        if (upperdentry)
 
347
                oe->__upperdentry = dget(upperdentry);
 
348
 
 
349
        if (lowerdentry)
 
350
                oe->lowerdentry = lowerdentry;
 
351
 
 
352
        dentry->d_fsdata = oe;
 
353
        dentry->d_op = &ovl_dentry_operations;
 
354
        d_add(dentry, inode);
 
355
 
 
356
        return 0;
 
357
 
 
358
out_dput:
 
359
        dput(lowerdentry);
 
360
out_dput_upper:
 
361
        dput(upperdentry);
 
362
out_put_dir:
 
363
        kfree(oe);
 
364
out:
 
365
        return err;
 
366
}
 
367
 
 
368
struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
 
369
                          struct nameidata *nd)
 
370
{
 
371
        int err = ovl_do_lookup(dentry);
 
372
 
 
373
        if (err)
 
374
                return ERR_PTR(err);
 
375
 
 
376
        return NULL;
 
377
}
 
378
 
 
379
struct file *ovl_path_open(struct path *path, int flags)
 
380
{
 
381
        path_get(path);
 
382
        return dentry_open(path->dentry, path->mnt, flags, current_cred());
 
383
}
 
384
 
 
385
static void ovl_put_super(struct super_block *sb)
 
386
{
 
387
        struct ovl_fs *ufs = sb->s_fs_info;
 
388
 
 
389
        if (!(sb->s_flags & MS_RDONLY))
 
390
                mnt_drop_write(ufs->upper_mnt);
 
391
 
 
392
        mntput(ufs->upper_mnt);
 
393
        mntput(ufs->lower_mnt);
 
394
 
 
395
        kfree(ufs->config.lowerdir);
 
396
        kfree(ufs->config.upperdir);
 
397
        kfree(ufs);
 
398
}
 
399
 
 
400
static int ovl_remount_fs(struct super_block *sb, int *flagsp, char *data)
 
401
{
 
402
        int flags = *flagsp;
 
403
        struct ovl_fs *ufs = sb->s_fs_info;
 
404
 
 
405
        /* When remounting rw or ro, we need to adjust the write access to the
 
406
         * upper fs.
 
407
         */
 
408
        if (((flags ^ sb->s_flags) & MS_RDONLY) == 0)
 
409
                /* No change to readonly status */
 
410
                return 0;
 
411
 
 
412
        if (flags & MS_RDONLY) {
 
413
                mnt_drop_write(ufs->upper_mnt);
 
414
                return 0;
 
415
        } else
 
416
                return mnt_want_write(ufs->upper_mnt);
 
417
}
 
418
 
 
419
/**
 
420
 * ovl_statfs
 
421
 * @sb: The overlayfs super block
 
422
 * @buf: The struct kstatfs to fill in with stats
 
423
 *
 
424
 * Get the filesystem statistics.  As writes always target the upper layer
 
425
 * filesystem pass the statfs to the same filesystem.
 
426
 */
 
427
static int ovl_statfs(struct dentry *dentry, struct kstatfs *buf)
 
428
{
 
429
        struct dentry *root_dentry = dentry->d_sb->s_root;
 
430
        struct path path;
 
431
        ovl_path_upper(root_dentry, &path);
 
432
 
 
433
        if (!path.dentry->d_sb->s_op->statfs)
 
434
                return -ENOSYS;
 
435
        return path.dentry->d_sb->s_op->statfs(path.dentry, buf);
 
436
}
 
437
 
 
438
/**
 
439
 * ovl_show_options
 
440
 *
 
441
 * Prints the mount options for a given superblock.
 
442
 * Returns zero; does not fail.
 
443
 */
 
444
static int ovl_show_options(struct seq_file *m, struct vfsmount *mnt)
 
445
{
 
446
        struct super_block *sb = mnt->mnt_sb;
 
447
        struct ovl_fs *ufs = sb->s_fs_info;
 
448
 
 
449
        seq_printf(m, ",lowerdir=%s", ufs->config.lowerdir);
 
450
        seq_printf(m, ",upperdir=%s", ufs->config.upperdir);
 
451
        return 0;
 
452
}
 
453
 
 
454
static const struct super_operations ovl_super_operations = {
 
455
        .put_super      = ovl_put_super,
 
456
        .remount_fs     = ovl_remount_fs,
 
457
        .statfs         = ovl_statfs,
 
458
        .show_options   = ovl_show_options,
 
459
};
 
460
 
 
461
enum {
 
462
        Opt_lowerdir,
 
463
        Opt_upperdir,
 
464
        Opt_err,
 
465
};
 
466
 
 
467
static const match_table_t ovl_tokens = {
 
468
        {Opt_lowerdir,                  "lowerdir=%s"},
 
469
        {Opt_upperdir,                  "upperdir=%s"},
 
470
        {Opt_err,                       NULL}
 
471
};
 
472
 
 
473
static int ovl_parse_opt(char *opt, struct ovl_config *config)
 
474
{
 
475
        char *p;
 
476
 
 
477
        config->upperdir = NULL;
 
478
        config->lowerdir = NULL;
 
479
 
 
480
        while ((p = strsep(&opt, ",")) != NULL) {
 
481
                int token;
 
482
                substring_t args[MAX_OPT_ARGS];
 
483
 
 
484
                if (!*p)
 
485
                        continue;
 
486
 
 
487
                token = match_token(p, ovl_tokens, args);
 
488
                switch (token) {
 
489
                case Opt_upperdir:
 
490
                        kfree(config->upperdir);
 
491
                        config->upperdir = match_strdup(&args[0]);
 
492
                        if (!config->upperdir)
 
493
                                return -ENOMEM;
 
494
                        break;
 
495
 
 
496
                case Opt_lowerdir:
 
497
                        kfree(config->lowerdir);
 
498
                        config->lowerdir = match_strdup(&args[0]);
 
499
                        if (!config->lowerdir)
 
500
                                return -ENOMEM;
 
501
                        break;
 
502
 
 
503
                default:
 
504
                        return -EINVAL;
 
505
                }
 
506
        }
 
507
        return 0;
 
508
}
 
509
 
 
510
static int ovl_fill_super(struct super_block *sb, void *data, int silent)
 
511
{
 
512
        struct path lowerpath;
 
513
        struct path upperpath;
 
514
        struct inode *root_inode;
 
515
        struct dentry *root_dentry;
 
516
        struct ovl_entry *oe;
 
517
        struct ovl_fs *ufs;
 
518
        int err;
 
519
 
 
520
        err = -ENOMEM;
 
521
        ufs = kmalloc(sizeof(struct ovl_fs), GFP_KERNEL);
 
522
        if (!ufs)
 
523
                goto out;
 
524
 
 
525
        err = ovl_parse_opt((char *) data, &ufs->config);
 
526
        if (err)
 
527
                goto out_free_ufs;
 
528
 
 
529
        err = -EINVAL;
 
530
        if (!ufs->config.upperdir || !ufs->config.lowerdir) {
 
531
                printk(KERN_ERR "overlayfs: missing upperdir or lowerdir\n");
 
532
                goto out_free_config;
 
533
        }
 
534
 
 
535
        oe = ovl_alloc_entry();
 
536
        if (oe == NULL)
 
537
                goto out_free_config;
 
538
 
 
539
        root_inode = ovl_new_inode(sb, S_IFDIR, oe);
 
540
        if (!root_inode)
 
541
                goto out_free_oe;
 
542
 
 
543
        err = kern_path(ufs->config.upperdir, LOOKUP_FOLLOW, &upperpath);
 
544
        if (err)
 
545
                goto out_put_root;
 
546
 
 
547
        err = kern_path(ufs->config.lowerdir, LOOKUP_FOLLOW, &lowerpath);
 
548
        if (err)
 
549
                goto out_put_upperpath;
 
550
 
 
551
        err = -ENOTDIR;
 
552
        if (!S_ISDIR(upperpath.dentry->d_inode->i_mode) ||
 
553
            !S_ISDIR(lowerpath.dentry->d_inode->i_mode))
 
554
                goto out_put_lowerpath;
 
555
 
 
556
        sb->s_stack_depth = max(upperpath.mnt->mnt_sb->s_stack_depth,
 
557
                                lowerpath.mnt->mnt_sb->s_stack_depth) + 1;
 
558
 
 
559
        err = -EINVAL;
 
560
        if (sb->s_stack_depth > FILESYSTEM_MAX_STACK_DEPTH) {
 
561
                printk(KERN_ERR "overlayfs: maximum fs stacking depth exceeded\n");
 
562
                goto out_put_lowerpath;
 
563
        }
 
564
 
 
565
 
 
566
        ufs->upper_mnt = clone_private_mount(&upperpath);
 
567
        err = PTR_ERR(ufs->upper_mnt);
 
568
        if (IS_ERR(ufs->upper_mnt)) {
 
569
                printk(KERN_ERR "overlayfs: failed to clone upperpath\n");
 
570
                goto out_put_lowerpath;
 
571
        }
 
572
 
 
573
        ufs->lower_mnt = clone_private_mount(&lowerpath);
 
574
        err = PTR_ERR(ufs->lower_mnt);
 
575
        if (IS_ERR(ufs->lower_mnt)) {
 
576
                printk(KERN_ERR "overlayfs: failed to clone lowerpath\n");
 
577
                goto out_put_upper_mnt;
 
578
        }
 
579
 
 
580
        /*
 
581
         * Make lower_mnt R/O.  That way fchmod/fchown on lower file
 
582
         * will fail instead of modifying lower fs.
 
583
         */
 
584
        ufs->lower_mnt->mnt_flags |= MNT_READONLY;
 
585
 
 
586
        /* If the upper fs is r/o, we mark overlayfs r/o too */
 
587
        if (ufs->upper_mnt->mnt_sb->s_flags & MS_RDONLY)
 
588
                sb->s_flags |= MS_RDONLY;
 
589
 
 
590
        if (!(sb->s_flags & MS_RDONLY)) {
 
591
                err = mnt_want_write(ufs->upper_mnt);
 
592
                if (err)
 
593
                        goto out_put_lower_mnt;
 
594
        }
 
595
 
 
596
        err = -ENOMEM;
 
597
        root_dentry = d_alloc_root(root_inode);
 
598
        if (!root_dentry)
 
599
                goto out_drop_write;
 
600
 
 
601
        mntput(upperpath.mnt);
 
602
        mntput(lowerpath.mnt);
 
603
 
 
604
        oe->__upperdentry = dget(upperpath.dentry);
 
605
        oe->lowerdentry = lowerpath.dentry;
 
606
 
 
607
        root_dentry->d_fsdata = oe;
 
608
        root_dentry->d_op = &ovl_dentry_operations;
 
609
 
 
610
        sb->s_op = &ovl_super_operations;
 
611
        sb->s_root = root_dentry;
 
612
        sb->s_fs_info = ufs;
 
613
 
 
614
        return 0;
 
615
 
 
616
out_drop_write:
 
617
        if (!(sb->s_flags & MS_RDONLY))
 
618
                mnt_drop_write(ufs->upper_mnt);
 
619
out_put_lower_mnt:
 
620
        mntput(ufs->lower_mnt);
 
621
out_put_upper_mnt:
 
622
        mntput(ufs->upper_mnt);
 
623
out_put_lowerpath:
 
624
        path_put(&lowerpath);
 
625
out_put_upperpath:
 
626
        path_put(&upperpath);
 
627
out_put_root:
 
628
        iput(root_inode);
 
629
out_free_oe:
 
630
        kfree(oe);
 
631
out_free_config:
 
632
        kfree(ufs->config.lowerdir);
 
633
        kfree(ufs->config.upperdir);
 
634
out_free_ufs:
 
635
        kfree(ufs);
 
636
out:
 
637
        return err;
 
638
}
 
639
 
 
640
static struct dentry *ovl_mount(struct file_system_type *fs_type, int flags,
 
641
                                const char *dev_name, void *raw_data)
 
642
{
 
643
        return mount_nodev(fs_type, flags, raw_data, ovl_fill_super);
 
644
}
 
645
 
 
646
static struct file_system_type ovl_fs_type = {
 
647
        .owner          = THIS_MODULE,
 
648
        .name           = "overlayfs",
 
649
        .mount          = ovl_mount,
 
650
        .kill_sb        = kill_anon_super,
 
651
};
 
652
 
 
653
static int __init ovl_init(void)
 
654
{
 
655
        return register_filesystem(&ovl_fs_type);
 
656
}
 
657
 
 
658
static void __exit ovl_exit(void)
 
659
{
 
660
        unregister_filesystem(&ovl_fs_type);
 
661
}
 
662
 
 
663
module_init(ovl_init);
 
664
module_exit(ovl_exit);