static int nilfs_ioctl_clean_segments(struct inode *inode, struct file *filp,
unsigned int cmd, void __user *argp)
{
- int ret;
-
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
-
- ret = nilfs_clean_segments(inode->i_sb, argp);
- clear_nilfs_cond_nongc_write(NILFS_SB(inode->i_sb)->s_nilfs);
- return ret;
-}
-
-static int nilfs_ioctl_test_cond(struct the_nilfs *nilfs, int cond)
-{
- return (cond & NILFS_TIMEDWAIT_SEG_WRITE) &&
- nilfs_cond_nongc_write(nilfs);
-}
-
-static void nilfs_ioctl_clear_cond(struct the_nilfs *nilfs, int cond)
-{
- if (cond & NILFS_TIMEDWAIT_SEG_WRITE)
- clear_nilfs_cond_nongc_write(nilfs);
-}
-
-static int nilfs_ioctl_timedwait(struct inode *inode, struct file *filp,
- unsigned int cmd, void __user *argp)
-{
- struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs;
- struct nilfs_wait_cond wc;
- long ret;
-
- if (!capable(CAP_SYS_ADMIN))
- return -EPERM;
- if (copy_from_user(&wc, argp, sizeof(wc)))
- return -EFAULT;
-
- unlock_kernel();
- ret = wc.wc_flags ?
- wait_event_interruptible_timeout(
- nilfs->ns_cleanerd_wq,
- nilfs_ioctl_test_cond(nilfs, wc.wc_cond),
- timespec_to_jiffies(&wc.wc_timeout)) :
- wait_event_interruptible(
- nilfs->ns_cleanerd_wq,
- nilfs_ioctl_test_cond(nilfs, wc.wc_cond));
- lock_kernel();
- nilfs_ioctl_clear_cond(nilfs, wc.wc_cond);
-
- if (ret > 0) {
- jiffies_to_timespec(ret, &wc.wc_timeout);
- if (copy_to_user(argp, &wc, sizeof(wc)))
- return -EFAULT;
- return 0;
- }
- if (ret != 0)
- return -EINTR;
-
- return wc.wc_flags ? -ETIME : 0;
+ return nilfs_clean_segments(inode->i_sb, argp);
}
static int nilfs_ioctl_sync(struct inode *inode, struct file *filp,
return nilfs_ioctl_get_bdescs(inode, filp, cmd, argp);
case NILFS_IOCTL_CLEAN_SEGMENTS:
return nilfs_ioctl_clean_segments(inode, filp, cmd, argp);
- case NILFS_IOCTL_TIMEDWAIT:
- return nilfs_ioctl_timedwait(inode, filp, cmd, argp);
case NILFS_IOCTL_SYNC:
return nilfs_ioctl_sync(inode, filp, cmd, argp);
default:
inode, filp, cmd, (unsigned long)uargv);
}
-static int
-nilfs_compat_ioctl_timedwait(struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg)
-{
- struct nilfs_wait_cond __user *uwcond;
- struct nilfs_wait_cond32 __user *uwcond32;
- struct timespec ts;
- int cond, flags, ret;
-
- uwcond = compat_alloc_user_space(sizeof(struct nilfs_wait_cond));
- uwcond32 = compat_ptr(arg);
- if (get_user(cond, &uwcond32->wc_cond) ||
- put_user(cond, &uwcond->wc_cond) ||
- get_user(flags, &uwcond32->wc_flags) ||
- put_user(flags, &uwcond->wc_flags) ||
- get_user(ts.tv_sec, &uwcond32->wc_timeout.tv_sec) ||
- get_user(ts.tv_nsec, &uwcond32->wc_timeout.tv_nsec) ||
- put_user(ts.tv_sec, &uwcond->wc_timeout.tv_sec) ||
- put_user(ts.tv_nsec, &uwcond->wc_timeout.tv_nsec))
- return -EFAULT;
-
- ret = nilfs_compat_locked_ioctl(inode, filp, cmd,
- (unsigned long)uwcond);
- if (ret < 0)
- return ret;
-
- if (get_user(ts.tv_sec, &uwcond->wc_timeout.tv_sec) ||
- get_user(ts.tv_nsec, &uwcond->wc_timeout.tv_nsec) ||
- put_user(ts.tv_sec, &uwcond32->wc_timeout.tv_sec) ||
- put_user(ts.tv_nsec, &uwcond32->wc_timeout.tv_nsec))
- return -EFAULT;
-
- return 0;
-}
-
static int nilfs_compat_ioctl_sync(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
case NILFS_IOCTL32_CLEAN_SEGMENTS:
return nilfs_compat_ioctl_clean_segments(
inode, filp, NILFS_IOCTL_CLEAN_SEGMENTS, arg);
- case NILFS_IOCTL32_TIMEDWAIT:
- return nilfs_compat_ioctl_timedwait(
- inode, filp, NILFS_IOCTL_TIMEDWAIT, arg);
case NILFS_IOCTL_SYNC:
return nilfs_compat_ioctl_sync(inode, filp, cmd, arg);
default:
THE_NILFS_LOADED, /* Roll-back/roll-forward has done and
the latest checkpoint was loaded */
THE_NILFS_DISCONTINUED, /* 'next' pointer chain has broken */
- THE_NILFS_COND_NONGC_WRITE, /* Condition to wake up cleanerd */
};
/**
* @ns_gc_dat: shadow inode of the DAT file inode for GC
* @ns_gc_inodes: dummy inodes to keep live blocks
* @ns_gc_inodes_h: hash list to keep dummy inode holding live blocks
- * @ns_cleanerd_wq: wait queue for cleanerd
* @ns_blocksize_bits: bit length of block size
* @ns_nsegments: number of segments in filesystem
* @ns_blocks_per_segment: number of blocks per segment
struct list_head ns_gc_inodes;
struct hlist_head *ns_gc_inodes_h;
- /* cleanerd */
- wait_queue_head_t ns_cleanerd_wq;
-
/* Disk layout information (static) */
unsigned int ns_blocksize_bits;
unsigned long ns_nsegments;
THE_NILFS_FNS(INIT, init)
THE_NILFS_FNS(LOADED, loaded)
THE_NILFS_FNS(DISCONTINUED, discontinued)
-THE_NILFS_FNS(COND_NONGC_WRITE, cond_nongc_write)
void nilfs_set_last_segment(struct the_nilfs *, sector_t, u64, __u64);
struct the_nilfs *alloc_nilfs(struct block_device *);
__u32 bd_level;
};
-#define NILFS_TIMEDWAIT_WRITE_LOCKED 0x1
-#define NILFS_TIMEDWAIT_SEG_WRITE 0x2
-
-/**
- * struct nilfs_wait_cond -
- */
-struct nilfs_wait_cond {
- int wc_cond;
- int wc_flags;
- struct timespec wc_timeout;
-};
-
#define NILFS_IOCTL_IDENT 'n'
#define NILFS_IOCTL_CHANGE_CPMODE \
_IOWR(NILFS_IOCTL_IDENT, 0x87, struct nilfs_argv)
#define NILFS_IOCTL_CLEAN_SEGMENTS \
_IOW(NILFS_IOCTL_IDENT, 0x88, struct nilfs_argv[5])
-#define NILFS_IOCTL_TIMEDWAIT \
- _IOWR(NILFS_IOCTL_IDENT, 0x89, struct nilfs_wait_cond)
#define NILFS_IOCTL_SYNC \
_IOR(NILFS_IOCTL_IDENT, 0x8A, __u64)
#define NILFS_IOCTL_RESIZE \
compat_time_t ss_nongc_ctime;
};
-struct nilfs_wait_cond32 {
- compat_int_t wc_cond;
- compat_int_t wc_flags;
- struct compat_timespec wc_timeout;
-};
-
#define NILFS_IOCTL32_CHANGE_CPMODE \
_IOW(NILFS_IOCTL_IDENT, 0x80, struct nilfs_cpmode32)
#define NILFS_IOCTL32_GET_CPINFO \
_IOWR(NILFS_IOCTL_IDENT, 0x87, struct nilfs_argv32)
#define NILFS_IOCTL32_CLEAN_SEGMENTS \
_IOW(NILFS_IOCTL_IDENT, 0x88, struct nilfs_argv32[5])
-#define NILFS_IOCTL32_TIMEDWAIT \
- _IOWR(NILFS_IOCTL_IDENT, 0x89, struct nilfs_wait_cond32)
#endif /* CONFIG_COMPAT */
#endif /* _LINUX_NILFS_FS_H */