2
* Copyright (C) 2008 Junjiro Okajima
4
* This program, aufs is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
* sub-routines for vfs in hinotify or dlgt mode
22
* $Id: hin_or_dlgt.c,v 1.1 2008/04/07 05:43:39 sfjro Exp $
24
// I'm going to slightly mad
28
#if !defined(CONFIG_AUFS_HINOTIFY) && !defined(CONFIG_AUFS_DLGT)
29
#error mis-configuraion or Makefile
32
/* ---------------------------------------------------------------------- */
34
struct permission_args {
41
static void call_permission(void *args)
43
struct permission_args *a = args;
44
*a->errp = do_vfsub_permission(a->inode, a->mask, a->nd);
47
int vfsub_permission(struct inode *inode, int mask, struct nameidata *nd,
51
return do_vfsub_permission(inode, mask, nd);
54
struct permission_args args = {
60
wkq_err = au_wkq_wait(call_permission, &args, /*dlgt*/1);
61
if (unlikely(wkq_err))
67
/* ---------------------------------------------------------------------- */
72
struct dentry *dentry;
77
static void call_create(void *args)
79
struct create_args *a = args;
80
*a->errp = do_vfsub_create(a->dir, a->dentry, a->mode, a->nd);
83
int vfsub_create(struct inode *dir, struct dentry *dentry, int mode,
84
struct nameidata *nd, int dlgt)
87
return do_vfsub_create(dir, dentry, mode, nd);
90
struct create_args args = {
97
wkq_err = au_wkq_wait(call_create, &args, /*dlgt*/1);
98
if (unlikely(wkq_err))
104
struct symlink_args {
107
struct dentry *dentry;
112
static void call_symlink(void *args)
114
struct symlink_args *a = args;
115
*a->errp = do_vfsub_symlink(a->dir, a->dentry, a->symname, a->mode);
118
int vfsub_symlink(struct inode *dir, struct dentry *dentry, const char *symname,
122
return do_vfsub_symlink(dir, dentry, symname, mode);
125
struct symlink_args args = {
132
wkq_err = au_wkq_wait(call_symlink, &args, /*dlgt*/1);
133
if (unlikely(wkq_err))
142
struct dentry *dentry;
147
static void call_mknod(void *args)
149
struct mknod_args *a = args;
150
*a->errp = do_vfsub_mknod(a->dir, a->dentry, a->mode, a->dev);
153
int vfsub_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev,
157
return do_vfsub_mknod(dir, dentry, mode, dev);
160
struct mknod_args args = {
167
wkq_err = au_wkq_wait(call_mknod, &args, /*dlgt*/1);
168
if (unlikely(wkq_err))
177
struct dentry *dentry;
181
static void call_mkdir(void *args)
183
struct mkdir_args *a = args;
184
*a->errp = do_vfsub_mkdir(a->dir, a->dentry, a->mode);
187
int vfsub_mkdir(struct inode *dir, struct dentry *dentry, int mode, int dlgt)
190
return do_vfsub_mkdir(dir, dentry, mode);
193
struct mkdir_args args = {
199
wkq_err = au_wkq_wait(call_mkdir, &args, /*dlgt*/1);
200
if (unlikely(wkq_err))
206
/* ---------------------------------------------------------------------- */
211
struct dentry *src_dentry, *dentry;
214
static void call_link(void *args)
216
struct link_args *a = args;
217
*a->errp = do_vfsub_link(a->src_dentry, a->dir, a->dentry);
220
int vfsub_link(struct dentry *src_dentry, struct inode *dir,
221
struct dentry *dentry, int dlgt)
224
return do_vfsub_link(src_dentry, dir, dentry);
227
struct link_args args = {
229
.src_dentry = src_dentry,
233
wkq_err = au_wkq_wait(call_link, &args, /*dlgt*/1);
234
if (unlikely(wkq_err))
242
struct inode *src_dir, *dir;
243
struct dentry *src_dentry, *dentry;
244
struct vfsub_args *vargs;
247
static void call_rename(void *args)
249
struct rename_args *a = args;
250
vfsub_ignore(a->vargs);
251
*a->errp = do_vfsub_rename(a->src_dir, a->src_dentry, a->dir,
253
if (unlikely(*a->errp))
254
vfsub_unignore(a->vargs);
257
int vfsub_rename(struct inode *src_dir, struct dentry *src_dentry,
258
struct inode *dir, struct dentry *dentry,
259
struct vfsub_args *vargs)
263
if (!vfsub_ftest(vargs->flags, DLGT)) {
265
err = do_vfsub_rename(src_dir, src_dentry, dir, dentry);
267
vfsub_unignore(vargs);
270
struct rename_args args = {
273
.src_dentry = src_dentry,
278
wkq_err = au_wkq_wait(call_rename, &args, /*dlgt*/1);
279
if (unlikely(wkq_err))
288
struct dentry *dentry;
289
struct vfsub_args *vargs;
292
static void call_rmdir(void *args)
294
struct rmdir_args *a = args;
295
vfsub_ignore(a->vargs);
296
*a->errp = do_vfsub_rmdir(a->dir, a->dentry);
297
if (unlikely(*a->errp))
298
vfsub_unignore(a->vargs);
301
int vfsub_rmdir(struct inode *dir, struct dentry *dentry,
302
struct vfsub_args *vargs)
306
if (!vfsub_ftest(vargs->flags, DLGT)) {
308
err = do_vfsub_rmdir(dir, dentry);
310
vfsub_unignore(vargs);
313
struct rmdir_args args = {
319
wkq_err = au_wkq_wait(call_rmdir, &args, /*dlgt*/1);
320
if (unlikely(wkq_err))
326
/* ---------------------------------------------------------------------- */
339
static void call_read_k(void *args)
341
struct read_args *a = args;
342
LKTRTrace("%.*s, cnt %lu, pos %Ld\n",
343
AuDLNPair(a->file->f_dentry), (unsigned long)a->count,
345
*a->errp = do_vfsub_read_k(a->file, a->kbuf, a->count, a->ppos);
348
ssize_t vfsub_read_u(struct file *file, char __user *ubuf, size_t count,
349
loff_t *ppos, int dlgt)
352
return do_vfsub_read_u(file, ubuf, count, ppos);
356
struct read_args args = {
363
if (unlikely(!count))
367
* workaround an application bug.
368
* generally, read(2) or write(2) may return the value shorter
369
* than requested. But many applications don't support it,
373
if (args.count > PAGE_SIZE)
374
args.count = PAGE_SIZE;
375
args.kbuf = kmalloc(args.count, GFP_TEMPORARY);
376
if (unlikely(!args.kbuf))
381
wkq_err = au_wkq_wait(call_read_k, &args, /*dlgt*/1);
382
if (unlikely(wkq_err))
385
&& copy_to_user(ubuf, args.kbuf, err))) {
390
else if (unlikely(err < 0))
393
/* do not read too much because of file i/o pointer */
394
if (count < args.count)
399
smp_mb(); /* flush ubuf */
409
ssize_t vfsub_read_k(struct file *file, void *kbuf, size_t count, loff_t *ppos,
413
return do_vfsub_read_k(file, kbuf, count, ppos);
417
struct read_args args = {
424
wkq_err = au_wkq_wait(call_read_k, &args, /*dlgt*/1);
425
if (unlikely(wkq_err))
436
const char __user *ubuf;
441
struct vfsub_args *vargs;
444
static void call_write_k(void *args)
446
struct write_args *a = args;
447
LKTRTrace("%.*s, cnt %lu, pos %Ld\n",
448
AuDLNPair(a->file->f_dentry), (unsigned long)a->count,
450
vfsub_ignore(a->vargs);
451
*a->errp = do_vfsub_write_k(a->file, a->kbuf, a->count, a->ppos);
452
if (unlikely(*a->errp < 0))
453
vfsub_unignore(a->vargs);
456
ssize_t vfsub_write_u(struct file *file, const char __user *ubuf, size_t count,
457
loff_t *ppos, struct vfsub_args *vargs)
461
if (!vfsub_ftest(vargs->flags, DLGT)) {
463
err = do_vfsub_write_u(file, ubuf, count, ppos);
464
if (unlikely(err < 0))
465
vfsub_unignore(vargs);
469
struct write_args args = {
477
if (unlikely(!count))
481
* workaround an application bug.
482
* generally, read(2) or write(2) may return the value shorter
483
* than requested. But many applications don't support it,
487
if (args.count > PAGE_SIZE)
488
args.count = PAGE_SIZE;
489
args.kbuf = kmalloc(args.count, GFP_TEMPORARY);
490
if (unlikely(!args.kbuf))
495
if (unlikely(copy_from_user(args.kbuf, ubuf,
501
wkq_err = au_wkq_wait(call_write_k, &args, /*dlgt*/1);
502
if (unlikely(wkq_err))
506
if (count < args.count)
512
else if (unlikely(err < 0))
524
ssize_t vfsub_write_k(struct file *file, void *kbuf, size_t count, loff_t *ppos,
525
struct vfsub_args *vargs)
529
if (!vfsub_ftest(vargs->flags, DLGT)) {
531
err = do_vfsub_write_k(file, kbuf, count, ppos);
532
if (unlikely(err < 0))
533
vfsub_unignore(vargs);
536
struct write_args args = {
544
wkq_err = au_wkq_wait(call_write_k, &args, /*dlgt*/1);
545
if (unlikely(wkq_err))
551
struct readdir_args {
558
static void call_readdir(void *args)
560
struct readdir_args *a = args;
561
*a->errp = do_vfsub_readdir(a->file, a->filldir, a->arg);
564
int vfsub_readdir(struct file *file, filldir_t filldir, void *arg, int dlgt)
567
return do_vfsub_readdir(file, filldir, arg);
570
struct readdir_args args = {
576
wkq_err = au_wkq_wait(call_readdir, &args, /*dlgt*/1);
577
if (unlikely(wkq_err))
583
/* ---------------------------------------------------------------------- */
585
struct splice_to_args {
589
struct pipe_inode_info *pipe;
594
static void call_splice_to(void *args)
596
struct splice_to_args *a = args;
597
*a->errp = do_vfsub_splice_to(a->in, a->ppos, a->pipe, a->len,
601
long vfsub_splice_to(struct file *in, loff_t *ppos,
602
struct pipe_inode_info *pipe, size_t len,
603
unsigned int flags, int dlgt)
606
return do_vfsub_splice_to(in, ppos, pipe, len, flags);
610
struct splice_to_args args = {
618
wkq_err = au_wkq_wait(call_splice_to, &args, /*dlgt*/1);
619
if (unlikely(wkq_err))
625
struct splice_from_args {
627
struct pipe_inode_info *pipe;
632
struct vfsub_args *vargs;
635
static void call_splice_from(void *args)
637
struct splice_from_args *a = args;
638
vfsub_ignore(a->vargs);
639
*a->errp = do_vfsub_splice_from(a->pipe, a->out, a->ppos, a->len,
641
if (unlikely(*a->errp < 0))
642
vfsub_unignore(a->vargs);
645
long vfsub_splice_from(struct pipe_inode_info *pipe, struct file *out,
646
loff_t *ppos, size_t len, unsigned int flags,
647
struct vfsub_args *vargs)
651
if (!vfsub_ftest(vargs->flags, DLGT)) {
653
err = do_vfsub_splice_from(pipe, out, ppos, len, flags);
654
if (unlikely(err < 0))
655
vfsub_unignore(vargs);
658
struct splice_from_args args = {
667
wkq_err = au_wkq_wait(call_splice_from, &args, /*dlgt*/1);
668
if (unlikely(wkq_err))
674
/* ---------------------------------------------------------------------- */
676
struct getattr_args {
678
struct vfsmount *mnt;
679
struct dentry *dentry;
683
static void call_getattr(void *args)
685
struct getattr_args *a = args;
686
*a->errp = do_vfsub_getattr(a->mnt, a->dentry, a->st);
689
int vfsub_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *st,
693
return do_vfsub_getattr(mnt, dentry, st);
696
struct getattr_args args = {
702
wkq_err = au_wkq_wait(call_getattr, &args, /*dlgt*/1);
703
if (unlikely(wkq_err))