Merge git://git.infradead.org/~dwmw2/firmware-2.6
[linux-2.6] / fs / nilfs2 / ioctl.c
1 /*
2  * ioctl.c - NILFS ioctl operations.
3  *
4  * Copyright (C) 2007, 2008 Nippon Telegraph and Telephone Corporation.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  * Written by Koji Sato <koji@osrg.net>.
21  */
22
23 #include <linux/fs.h>
24 #include <linux/wait.h>
25 #include <linux/smp_lock.h>     /* lock_kernel(), unlock_kernel() */
26 #include <linux/capability.h>   /* capable() */
27 #include <linux/uaccess.h>      /* copy_from_user(), copy_to_user() */
28 #include <linux/vmalloc.h>
29 #include <linux/nilfs2_fs.h>
30 #include "nilfs.h"
31 #include "segment.h"
32 #include "bmap.h"
33 #include "cpfile.h"
34 #include "sufile.h"
35 #include "dat.h"
36
37
38 static int nilfs_ioctl_wrap_copy(struct the_nilfs *nilfs,
39                                  struct nilfs_argv *argv, int dir,
40                                  ssize_t (*dofunc)(struct the_nilfs *,
41                                                    __u64 *, int,
42                                                    void *, size_t, size_t))
43 {
44         void *buf;
45         void __user *base = (void __user *)(unsigned long)argv->v_base;
46         size_t maxmembs, total, n;
47         ssize_t nr;
48         int ret, i;
49         __u64 pos, ppos;
50
51         if (argv->v_nmembs == 0)
52                 return 0;
53
54         if (argv->v_size > PAGE_SIZE)
55                 return -EINVAL;
56
57         buf = (void *)__get_free_pages(GFP_NOFS, 0);
58         if (unlikely(!buf))
59                 return -ENOMEM;
60         maxmembs = PAGE_SIZE / argv->v_size;
61
62         ret = 0;
63         total = 0;
64         pos = argv->v_index;
65         for (i = 0; i < argv->v_nmembs; i += n) {
66                 n = (argv->v_nmembs - i < maxmembs) ?
67                         argv->v_nmembs - i : maxmembs;
68                 if ((dir & _IOC_WRITE) &&
69                     copy_from_user(buf, base + argv->v_size * i,
70                                    argv->v_size * n)) {
71                         ret = -EFAULT;
72                         break;
73                 }
74                 ppos = pos;
75                 nr = dofunc(nilfs, &pos, argv->v_flags, buf, argv->v_size,
76                                n);
77                 if (nr < 0) {
78                         ret = nr;
79                         break;
80                 }
81                 if ((dir & _IOC_READ) &&
82                     copy_to_user(base + argv->v_size * i, buf,
83                                  argv->v_size * nr)) {
84                         ret = -EFAULT;
85                         break;
86                 }
87                 total += nr;
88                 if ((size_t)nr < n)
89                         break;
90                 if (pos == ppos)
91                         pos += n;
92         }
93         argv->v_nmembs = total;
94
95         free_pages((unsigned long)buf, 0);
96         return ret;
97 }
98
99 static int nilfs_ioctl_change_cpmode(struct inode *inode, struct file *filp,
100                                      unsigned int cmd, void __user *argp)
101 {
102         struct inode *cpfile = NILFS_SB(inode->i_sb)->s_nilfs->ns_cpfile;
103         struct nilfs_transaction_info ti;
104         struct nilfs_cpmode cpmode;
105         int ret;
106
107         if (!capable(CAP_SYS_ADMIN))
108                 return -EPERM;
109         if (copy_from_user(&cpmode, argp, sizeof(cpmode)))
110                 return -EFAULT;
111
112         nilfs_transaction_begin(inode->i_sb, &ti, 0);
113         ret = nilfs_cpfile_change_cpmode(
114                 cpfile, cpmode.cm_cno, cpmode.cm_mode);
115         if (unlikely(ret < 0)) {
116                 nilfs_transaction_abort(inode->i_sb);
117                 return ret;
118         }
119         nilfs_transaction_commit(inode->i_sb); /* never fails */
120         return ret;
121 }
122
123 static int
124 nilfs_ioctl_delete_checkpoint(struct inode *inode, struct file *filp,
125                               unsigned int cmd, void __user *argp)
126 {
127         struct inode *cpfile = NILFS_SB(inode->i_sb)->s_nilfs->ns_cpfile;
128         struct nilfs_transaction_info ti;
129         __u64 cno;
130         int ret;
131
132         if (!capable(CAP_SYS_ADMIN))
133                 return -EPERM;
134         if (copy_from_user(&cno, argp, sizeof(cno)))
135                 return -EFAULT;
136
137         nilfs_transaction_begin(inode->i_sb, &ti, 0);
138         ret = nilfs_cpfile_delete_checkpoint(cpfile, cno);
139         if (unlikely(ret < 0)) {
140                 nilfs_transaction_abort(inode->i_sb);
141                 return ret;
142         }
143         nilfs_transaction_commit(inode->i_sb); /* never fails */
144         return ret;
145 }
146
147 static ssize_t
148 nilfs_ioctl_do_get_cpinfo(struct the_nilfs *nilfs, __u64 *posp, int flags,
149                           void *buf, size_t size, size_t nmembs)
150 {
151         int ret;
152
153         down_read(&nilfs->ns_segctor_sem);
154         ret = nilfs_cpfile_get_cpinfo(nilfs->ns_cpfile, posp, flags, buf,
155                                       nmembs);
156         up_read(&nilfs->ns_segctor_sem);
157         return ret;
158 }
159
160 static int nilfs_ioctl_get_cpstat(struct inode *inode, struct file *filp,
161                                   unsigned int cmd, void __user *argp)
162 {
163         struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs;
164         struct nilfs_cpstat cpstat;
165         int ret;
166
167         down_read(&nilfs->ns_segctor_sem);
168         ret = nilfs_cpfile_get_stat(nilfs->ns_cpfile, &cpstat);
169         up_read(&nilfs->ns_segctor_sem);
170         if (ret < 0)
171                 return ret;
172
173         if (copy_to_user(argp, &cpstat, sizeof(cpstat)))
174                 ret = -EFAULT;
175         return ret;
176 }
177
178 static ssize_t
179 nilfs_ioctl_do_get_suinfo(struct the_nilfs *nilfs, __u64 *posp, int flags,
180                           void *buf, size_t size, size_t nmembs)
181 {
182         int ret;
183
184         down_read(&nilfs->ns_segctor_sem);
185         ret = nilfs_sufile_get_suinfo(nilfs->ns_sufile, *posp, buf, nmembs);
186         up_read(&nilfs->ns_segctor_sem);
187         return ret;
188 }
189
190 static int nilfs_ioctl_get_sustat(struct inode *inode, struct file *filp,
191                                   unsigned int cmd, void __user *argp)
192 {
193         struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs;
194         struct nilfs_sustat sustat;
195         int ret;
196
197         down_read(&nilfs->ns_segctor_sem);
198         ret = nilfs_sufile_get_stat(nilfs->ns_sufile, &sustat);
199         up_read(&nilfs->ns_segctor_sem);
200         if (ret < 0)
201                 return ret;
202
203         if (copy_to_user(argp, &sustat, sizeof(sustat)))
204                 ret = -EFAULT;
205         return ret;
206 }
207
208 static ssize_t
209 nilfs_ioctl_do_get_vinfo(struct the_nilfs *nilfs, __u64 *posp, int flags,
210                          void *buf, size_t size, size_t nmembs)
211 {
212         int ret;
213
214         down_read(&nilfs->ns_segctor_sem);
215         ret = nilfs_dat_get_vinfo(nilfs_dat_inode(nilfs), buf, nmembs);
216         up_read(&nilfs->ns_segctor_sem);
217         return ret;
218 }
219
220 static ssize_t
221 nilfs_ioctl_do_get_bdescs(struct the_nilfs *nilfs, __u64 *posp, int flags,
222                           void *buf, size_t size, size_t nmembs)
223 {
224         struct inode *dat = nilfs_dat_inode(nilfs);
225         struct nilfs_bmap *bmap = NILFS_I(dat)->i_bmap;
226         struct nilfs_bdesc *bdescs = buf;
227         int ret, i;
228
229         down_read(&nilfs->ns_segctor_sem);
230         for (i = 0; i < nmembs; i++) {
231                 ret = nilfs_bmap_lookup_at_level(bmap,
232                                                  bdescs[i].bd_offset,
233                                                  bdescs[i].bd_level + 1,
234                                                  &bdescs[i].bd_blocknr);
235                 if (ret < 0) {
236                         if (ret != -ENOENT) {
237                                 up_read(&nilfs->ns_segctor_sem);
238                                 return ret;
239                         }
240                         bdescs[i].bd_blocknr = 0;
241                 }
242         }
243         up_read(&nilfs->ns_segctor_sem);
244         return nmembs;
245 }
246
247 static int nilfs_ioctl_get_bdescs(struct inode *inode, struct file *filp,
248                                   unsigned int cmd, void __user *argp)
249 {
250         struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs;
251         struct nilfs_argv argv;
252         int ret;
253
254         if (copy_from_user(&argv, argp, sizeof(argv)))
255                 return -EFAULT;
256
257         if (argv.v_size != sizeof(struct nilfs_bdesc))
258                 return -EINVAL;
259
260         ret = nilfs_ioctl_wrap_copy(nilfs, &argv, _IOC_DIR(cmd),
261                                     nilfs_ioctl_do_get_bdescs);
262         if (ret < 0)
263                 return ret;
264
265         if (copy_to_user(argp, &argv, sizeof(argv)))
266                 ret = -EFAULT;
267         return ret;
268 }
269
270 static int nilfs_ioctl_move_inode_block(struct inode *inode,
271                                         struct nilfs_vdesc *vdesc,
272                                         struct list_head *buffers)
273 {
274         struct buffer_head *bh;
275         int ret;
276
277         if (vdesc->vd_flags == 0)
278                 ret = nilfs_gccache_submit_read_data(
279                         inode, vdesc->vd_offset, vdesc->vd_blocknr,
280                         vdesc->vd_vblocknr, &bh);
281         else
282                 ret = nilfs_gccache_submit_read_node(
283                         inode, vdesc->vd_blocknr, vdesc->vd_vblocknr, &bh);
284
285         if (unlikely(ret < 0)) {
286                 if (ret == -ENOENT)
287                         printk(KERN_CRIT
288                                "%s: invalid virtual block address (%s): "
289                                "ino=%llu, cno=%llu, offset=%llu, "
290                                "blocknr=%llu, vblocknr=%llu\n",
291                                __func__, vdesc->vd_flags ? "node" : "data",
292                                (unsigned long long)vdesc->vd_ino,
293                                (unsigned long long)vdesc->vd_cno,
294                                (unsigned long long)vdesc->vd_offset,
295                                (unsigned long long)vdesc->vd_blocknr,
296                                (unsigned long long)vdesc->vd_vblocknr);
297                 return ret;
298         }
299         bh->b_private = vdesc;
300         list_add_tail(&bh->b_assoc_buffers, buffers);
301         return 0;
302 }
303
304 static int nilfs_ioctl_move_blocks(struct the_nilfs *nilfs,
305                                    struct nilfs_argv *argv, void *buf)
306 {
307         size_t nmembs = argv->v_nmembs;
308         struct inode *inode;
309         struct nilfs_vdesc *vdesc;
310         struct buffer_head *bh, *n;
311         LIST_HEAD(buffers);
312         ino_t ino;
313         __u64 cno;
314         int i, ret;
315
316         for (i = 0, vdesc = buf; i < nmembs; ) {
317                 ino = vdesc->vd_ino;
318                 cno = vdesc->vd_cno;
319                 inode = nilfs_gc_iget(nilfs, ino, cno);
320                 if (unlikely(inode == NULL)) {
321                         ret = -ENOMEM;
322                         goto failed;
323                 }
324                 do {
325                         ret = nilfs_ioctl_move_inode_block(inode, vdesc,
326                                                            &buffers);
327                         if (unlikely(ret < 0))
328                                 goto failed;
329                         vdesc++;
330                 } while (++i < nmembs &&
331                          vdesc->vd_ino == ino && vdesc->vd_cno == cno);
332         }
333
334         list_for_each_entry_safe(bh, n, &buffers, b_assoc_buffers) {
335                 ret = nilfs_gccache_wait_and_mark_dirty(bh);
336                 if (unlikely(ret < 0)) {
337                         if (ret == -EEXIST) {
338                                 vdesc = bh->b_private;
339                                 printk(KERN_CRIT
340                                        "%s: conflicting %s buffer: "
341                                        "ino=%llu, cno=%llu, offset=%llu, "
342                                        "blocknr=%llu, vblocknr=%llu\n",
343                                        __func__,
344                                        vdesc->vd_flags ? "node" : "data",
345                                        (unsigned long long)vdesc->vd_ino,
346                                        (unsigned long long)vdesc->vd_cno,
347                                        (unsigned long long)vdesc->vd_offset,
348                                        (unsigned long long)vdesc->vd_blocknr,
349                                        (unsigned long long)vdesc->vd_vblocknr);
350                         }
351                         goto failed;
352                 }
353                 list_del_init(&bh->b_assoc_buffers);
354                 bh->b_private = NULL;
355                 brelse(bh);
356         }
357         return nmembs;
358
359  failed:
360         list_for_each_entry_safe(bh, n, &buffers, b_assoc_buffers) {
361                 list_del_init(&bh->b_assoc_buffers);
362                 bh->b_private = NULL;
363                 brelse(bh);
364         }
365         return ret;
366 }
367
368 static int nilfs_ioctl_delete_checkpoints(struct the_nilfs *nilfs,
369                                           struct nilfs_argv *argv, void *buf)
370 {
371         size_t nmembs = argv->v_nmembs;
372         struct inode *cpfile = nilfs->ns_cpfile;
373         struct nilfs_period *periods = buf;
374         int ret, i;
375
376         for (i = 0; i < nmembs; i++) {
377                 ret = nilfs_cpfile_delete_checkpoints(
378                         cpfile, periods[i].p_start, periods[i].p_end);
379                 if (ret < 0)
380                         return ret;
381         }
382         return nmembs;
383 }
384
385 static int nilfs_ioctl_free_vblocknrs(struct the_nilfs *nilfs,
386                                       struct nilfs_argv *argv, void *buf)
387 {
388         size_t nmembs = argv->v_nmembs;
389         int ret;
390
391         ret = nilfs_dat_freev(nilfs_dat_inode(nilfs), buf, nmembs);
392
393         return (ret < 0) ? ret : nmembs;
394 }
395
396 static int nilfs_ioctl_mark_blocks_dirty(struct the_nilfs *nilfs,
397                                          struct nilfs_argv *argv, void *buf)
398 {
399         size_t nmembs = argv->v_nmembs;
400         struct inode *dat = nilfs_dat_inode(nilfs);
401         struct nilfs_bmap *bmap = NILFS_I(dat)->i_bmap;
402         struct nilfs_bdesc *bdescs = buf;
403         int ret, i;
404
405         for (i = 0; i < nmembs; i++) {
406                 /* XXX: use macro or inline func to check liveness */
407                 ret = nilfs_bmap_lookup_at_level(bmap,
408                                                  bdescs[i].bd_offset,
409                                                  bdescs[i].bd_level + 1,
410                                                  &bdescs[i].bd_blocknr);
411                 if (ret < 0) {
412                         if (ret != -ENOENT)
413                                 return ret;
414                         bdescs[i].bd_blocknr = 0;
415                 }
416                 if (bdescs[i].bd_blocknr != bdescs[i].bd_oblocknr)
417                         /* skip dead block */
418                         continue;
419                 if (bdescs[i].bd_level == 0) {
420                         ret = nilfs_mdt_mark_block_dirty(dat,
421                                                          bdescs[i].bd_offset);
422                         if (ret < 0) {
423                                 WARN_ON(ret == -ENOENT);
424                                 return ret;
425                         }
426                 } else {
427                         ret = nilfs_bmap_mark(bmap, bdescs[i].bd_offset,
428                                               bdescs[i].bd_level);
429                         if (ret < 0) {
430                                 WARN_ON(ret == -ENOENT);
431                                 return ret;
432                         }
433                 }
434         }
435         return nmembs;
436 }
437
438 static int nilfs_ioctl_free_segments(struct the_nilfs *nilfs,
439                                      struct nilfs_argv *argv, void *buf)
440 {
441         size_t nmembs = argv->v_nmembs;
442         struct nilfs_sb_info *sbi = nilfs->ns_writer;
443         int ret;
444
445         if (unlikely(!sbi)) {
446                 /* never happens because called for a writable mount */
447                 WARN_ON(1);
448                 return -EROFS;
449         }
450         ret = nilfs_segctor_add_segments_to_be_freed(
451                 NILFS_SC(sbi), buf, nmembs);
452
453         return (ret < 0) ? ret : nmembs;
454 }
455
456 int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *nilfs,
457                                        struct nilfs_argv *argv, void **kbufs)
458 {
459         const char *msg;
460         int ret;
461
462         ret = nilfs_ioctl_move_blocks(nilfs, &argv[0], kbufs[0]);
463         if (ret < 0) {
464                 msg = "cannot read source blocks";
465                 goto failed;
466         }
467
468         ret = nilfs_ioctl_delete_checkpoints(nilfs, &argv[1], kbufs[1]);
469         if (ret < 0) {
470                 /*
471                  * can safely abort because checkpoints can be removed
472                  * independently.
473                  */
474                 msg = "cannot delete checkpoints";
475                 goto failed;
476         }
477         ret = nilfs_ioctl_free_vblocknrs(nilfs, &argv[2], kbufs[2]);
478         if (ret < 0) {
479                 /*
480                  * can safely abort because DAT file is updated atomically
481                  * using a copy-on-write technique.
482                  */
483                 msg = "cannot delete virtual blocks from DAT file";
484                 goto failed;
485         }
486         ret = nilfs_ioctl_mark_blocks_dirty(nilfs, &argv[3], kbufs[3]);
487         if (ret < 0) {
488                 /*
489                  * can safely abort because the operation is nondestructive.
490                  */
491                 msg = "cannot mark copying blocks dirty";
492                 goto failed;
493         }
494         ret = nilfs_ioctl_free_segments(nilfs, &argv[4], kbufs[4]);
495         if (ret < 0) {
496                 /*
497                  * can safely abort because this operation is atomic.
498                  */
499                 msg = "cannot set segments to be freed";
500                 goto failed;
501         }
502         return 0;
503
504  failed:
505         nilfs_remove_all_gcinode(nilfs);
506         printk(KERN_ERR "NILFS: GC failed during preparation: %s: err=%d\n",
507                msg, ret);
508         return ret;
509 }
510
511 static int nilfs_ioctl_clean_segments(struct inode *inode, struct file *filp,
512                                       unsigned int cmd, void __user *argp)
513 {
514         struct nilfs_argv argv[5];
515         const static size_t argsz[5] = {
516                 sizeof(struct nilfs_vdesc),
517                 sizeof(struct nilfs_period),
518                 sizeof(__u64),
519                 sizeof(struct nilfs_bdesc),
520                 sizeof(__u64),
521         };
522         void __user *base;
523         void *kbufs[5];
524         struct the_nilfs *nilfs;
525         size_t len, nsegs;
526         int n, ret;
527
528         if (!capable(CAP_SYS_ADMIN))
529                 return -EPERM;
530
531         if (copy_from_user(argv, argp, sizeof(argv)))
532                 return -EFAULT;
533
534         nsegs = argv[4].v_nmembs;
535         if (argv[4].v_size != argsz[4])
536                 return -EINVAL;
537         /*
538          * argv[4] points to segment numbers this ioctl cleans.  We
539          * use kmalloc() for its buffer because memory used for the
540          * segment numbers is enough small.
541          */
542         kbufs[4] = memdup_user((void __user *)(unsigned long)argv[4].v_base,
543                                nsegs * sizeof(__u64));
544         if (IS_ERR(kbufs[4]))
545                 return PTR_ERR(kbufs[4]);
546
547         nilfs = NILFS_SB(inode->i_sb)->s_nilfs;
548
549         for (n = 0; n < 4; n++) {
550                 ret = -EINVAL;
551                 if (argv[n].v_size != argsz[n])
552                         goto out_free;
553
554                 if (argv[n].v_nmembs > nsegs * nilfs->ns_blocks_per_segment)
555                         goto out_free;
556
557                 len = argv[n].v_size * argv[n].v_nmembs;
558                 base = (void __user *)(unsigned long)argv[n].v_base;
559                 if (len == 0) {
560                         kbufs[n] = NULL;
561                         continue;
562                 }
563
564                 kbufs[n] = vmalloc(len);
565                 if (!kbufs[n]) {
566                         ret = -ENOMEM;
567                         goto out_free;
568                 }
569                 if (copy_from_user(kbufs[n], base, len)) {
570                         ret = -EFAULT;
571                         vfree(kbufs[n]);
572                         goto out_free;
573                 }
574         }
575
576         ret = nilfs_clean_segments(inode->i_sb, argv, kbufs);
577
578  out_free:
579         while (--n >= 0)
580                 vfree(kbufs[n]);
581         kfree(kbufs[4]);
582         return ret;
583 }
584
585 static int nilfs_ioctl_sync(struct inode *inode, struct file *filp,
586                             unsigned int cmd, void __user *argp)
587 {
588         __u64 cno;
589         int ret;
590
591         ret = nilfs_construct_segment(inode->i_sb);
592         if (ret < 0)
593                 return ret;
594
595         if (argp != NULL) {
596                 cno = NILFS_SB(inode->i_sb)->s_nilfs->ns_cno - 1;
597                 if (copy_to_user(argp, &cno, sizeof(cno)))
598                         return -EFAULT;
599         }
600         return 0;
601 }
602
603 static int nilfs_ioctl_get_info(struct inode *inode, struct file *filp,
604                                 unsigned int cmd, void __user *argp,
605                                 size_t membsz,
606                                 ssize_t (*dofunc)(struct the_nilfs *,
607                                                   __u64 *, int,
608                                                   void *, size_t, size_t))
609
610 {
611         struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs;
612         struct nilfs_argv argv;
613         int ret;
614
615         if (copy_from_user(&argv, argp, sizeof(argv)))
616                 return -EFAULT;
617
618         if (argv.v_size != membsz)
619                 return -EINVAL;
620
621         ret = nilfs_ioctl_wrap_copy(nilfs, &argv, _IOC_DIR(cmd), dofunc);
622         if (ret < 0)
623                 return ret;
624
625         if (copy_to_user(argp, &argv, sizeof(argv)))
626                 ret = -EFAULT;
627         return ret;
628 }
629
630 long nilfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
631 {
632         struct inode *inode = filp->f_dentry->d_inode;
633         void __user *argp = (void * __user *)arg;
634
635         switch (cmd) {
636         case NILFS_IOCTL_CHANGE_CPMODE:
637                 return nilfs_ioctl_change_cpmode(inode, filp, cmd, argp);
638         case NILFS_IOCTL_DELETE_CHECKPOINT:
639                 return nilfs_ioctl_delete_checkpoint(inode, filp, cmd, argp);
640         case NILFS_IOCTL_GET_CPINFO:
641                 return nilfs_ioctl_get_info(inode, filp, cmd, argp,
642                                             sizeof(struct nilfs_cpinfo),
643                                             nilfs_ioctl_do_get_cpinfo);
644         case NILFS_IOCTL_GET_CPSTAT:
645                 return nilfs_ioctl_get_cpstat(inode, filp, cmd, argp);
646         case NILFS_IOCTL_GET_SUINFO:
647                 return nilfs_ioctl_get_info(inode, filp, cmd, argp,
648                                             sizeof(struct nilfs_suinfo),
649                                             nilfs_ioctl_do_get_suinfo);
650         case NILFS_IOCTL_GET_SUSTAT:
651                 return nilfs_ioctl_get_sustat(inode, filp, cmd, argp);
652         case NILFS_IOCTL_GET_VINFO:
653                 return nilfs_ioctl_get_info(inode, filp, cmd, argp,
654                                             sizeof(struct nilfs_vinfo),
655                                             nilfs_ioctl_do_get_vinfo);
656         case NILFS_IOCTL_GET_BDESCS:
657                 return nilfs_ioctl_get_bdescs(inode, filp, cmd, argp);
658         case NILFS_IOCTL_CLEAN_SEGMENTS:
659                 return nilfs_ioctl_clean_segments(inode, filp, cmd, argp);
660         case NILFS_IOCTL_SYNC:
661                 return nilfs_ioctl_sync(inode, filp, cmd, argp);
662         default:
663                 return -ENOTTY;
664         }
665 }