* [PATCH 1/3] Add ioctl to set per file 'compress' flag
@ 2009-06-13 1:49 Amit Gud
2009-06-15 13:24 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Amit Gud @ 2009-06-13 1:49 UTC (permalink / raw)
To: chris.mason, linux-btrfs; +Cc: gud
An ioctl is needed to set compress flag (i.e. clear
BTRFS_INODE_NOCOMPRESS flag) on per file basis. This patch adds that.
Introduces a generic function to be used by subsequent patches.
Signed-off-by: Amit Gud <gud@ksu.edu>
Index: newformat2/fs/btrfs/ioctl.c
===================================================================
--- newformat2.orig/fs/btrfs/ioctl.c
+++ newformat2/fs/btrfs/ioctl.c
@@ -1240,6 +1240,54 @@ out:
return ret;
}
+/* Ioctl function to set or clear a flag on the file. */
+static long btrfs_ioctl_inode_flag(struct file *file,
+ u32 flag, int set)
+{
+ struct inode *inode = file->f_path.dentry->d_inode;
+ struct btrfs_inode *ip = BTRFS_I(inode);
+ struct btrfs_root *root = ip->root;
+ struct btrfs_trans_handle *trans;
+ int ret;
+
+ if (!is_owner_or_cap(inode))
+ return -EACCES;
+
+ mutex_lock(&inode->i_mutex);
+
+ /* Bail out if already set / cleared. */
+ if (set) {
+ if (ip->flags & flag)
+ goto out_unlock;
+ } else {
+ if (!(ip->flags & flag))
+ goto out_unlock;
+ }
+
+ ret = mnt_want_write(file->f_path.mnt);
+ if (ret)
+ goto out_unlock;
+
+ if (set)
+ ip->flags |= flag;
+ else
+ ip->flags &= ~flag;
+
+ trans = btrfs_join_transaction(root, 1);
+ BUG_ON(!trans);
+
+ ret = btrfs_update_inode(trans, root, inode);
+ BUG_ON(ret);
+
+ inode->i_ctime = CURRENT_TIME;
+ btrfs_end_transaction(trans, root);
+
+ mnt_drop_write(file->f_path.mnt);
+ out_unlock:
+ mutex_unlock(&inode->i_mutex);
+ return 0;
+}
+
long btrfs_ioctl(struct file *file, unsigned int
cmd, unsigned long arg)
{
@@ -1278,6 +1326,8 @@ long btrfs_ioctl(struct file *file, unsi
case BTRFS_IOC_SYNC:
btrfs_sync_fs(file->f_dentry->d_sb, 1);
return 0;
+ case BTRFS_IOC_COMPRESS:
+ return btrfs_ioctl_inode_flag(file, BTRFS_INODE_NOCOMPRESS, 0);
}
return -ENOTTY;
Index: newformat2/fs/btrfs/ioctl.h
===================================================================
--- newformat2.orig/fs/btrfs/ioctl.h
+++ newformat2/fs/btrfs/ioctl.h
@@ -65,5 +65,7 @@ struct btrfs_ioctl_clone_range_args {
#define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, \
struct btrfs_ioctl_vol_args)
+#define BTRFS_IOC_COMPRESS _IOW(BTRFS_IOCTL_MAGIC, 15, \
+ struct btrfs_ioctl_vol_args)
#endif
--
May the source be with you.
http://www.cis.ksu.edu/~gud
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 1/3] Add ioctl to set per file 'compress' flag
2009-06-13 1:49 [PATCH 1/3] Add ioctl to set per file 'compress' flag Amit Gud
@ 2009-06-15 13:24 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2009-06-15 13:24 UTC (permalink / raw)
To: Amit Gud; +Cc: chris.mason, linux-btrfs, gud
On Fri, Jun 12, 2009 at 06:49:45PM -0700, Amit Gud wrote:
>
> An ioctl is needed to set compress flag (i.e. clear
> BTRFS_INODE_NOCOMPRESS flag) on per file basis. This patch adds that.
>
> Introduces a generic function to be used by subsequent patches.
It's probably a better idea to fit these into the existing per-inode
flags. This will need some coordination with Ted on how to re-use
the existing compression flags if at all and where to fit the new
flags in the numerical namespaces.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-06-15 13:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-13 1:49 [PATCH 1/3] Add ioctl to set per file 'compress' flag Amit Gud
2009-06-15 13:24 ` Christoph Hellwig
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.