aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/super.c
diff options
context:
space:
mode:
authorTom Van Braeckel <tomvanbraeckel@gmail.com>2015-03-24 11:35:49 -0400
committerChris Mason <clm@fb.com>2015-03-26 21:10:24 -0400
commitd8620958296e4fa61afde421f1de16a5c2234b28 (patch)
tree23fdbb199dd476ae5acae908f87803d974dc648e /fs/btrfs/super.c
parent26e726afe01c1c82072cf23a5ed89ce25f39d9f2 (diff)
btrfs: explicitly set control file's private_data
The private_data member of the Btrfs control device file (/dev/btrfs-control) is used to hold the current transaction and needs to be initialized to NULL to signify that no transaction is in progress. We explicitly set the control file's private_data to NULL to be independent of whatever value the misc subsystem initializes it to. Backstory: ---------- The misc subsystem (which is used by /dev/btrfs-control) initializes a file's private_data to point to the misc device when a driver has registered a custom open file operation and initializes it to NULL when a custom open file operation has *not* been provided. This subtle quirk is confusing, to the point where kernel code registers *empty* file open operations to have private_data point to the misc device structure. And it leads to bugs, where the addition or removal of a custom open file operation surprisingly changes the initial contents of a file's private_data structure. To simplify things in the misc subsystem, a patch [1] has been proposed to *always* set private_data to point to the misc device instead of only doing this when a custom open file operation has been registered. But before we can fix this in the misc subsystem itself, we need to modify the (few) drivers that rely on this very subtle behavior. [1] https://lkml.org/lkml/2014/12/4/939 Signed-off-by: Martin Kepplinger <martink@posteo.de> Signed-off-by: Tom Van Braeckel <tomvanbraeckel@gmail.com> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r--fs/btrfs/super.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index db7d7b803a61..eb67ca44ad51 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1908,6 +1908,17 @@ static struct file_system_type btrfs_fs_type = {
1908}; 1908};
1909MODULE_ALIAS_FS("btrfs"); 1909MODULE_ALIAS_FS("btrfs");
1910 1910
1911static int btrfs_control_open(struct inode *inode, struct file *file)
1912{
1913 /*
1914 * The control file's private_data is used to hold the
1915 * transaction when it is started and is used to keep
1916 * track of whether a transaction is already in progress.
1917 */
1918 file->private_data = NULL;
1919 return 0;
1920}
1921
1911/* 1922/*
1912 * used by btrfsctl to scan devices when no FS is mounted 1923 * used by btrfsctl to scan devices when no FS is mounted
1913 */ 1924 */
@@ -2009,6 +2020,7 @@ static const struct super_operations btrfs_super_ops = {
2009}; 2020};
2010 2021
2011static const struct file_operations btrfs_ctl_fops = { 2022static const struct file_operations btrfs_ctl_fops = {
2023 .open = btrfs_control_open,
2012 .unlocked_ioctl = btrfs_control_ioctl, 2024 .unlocked_ioctl = btrfs_control_ioctl,
2013 .compat_ioctl = btrfs_control_ioctl, 2025 .compat_ioctl = btrfs_control_ioctl,
2014 .owner = THIS_MODULE, 2026 .owner = THIS_MODULE,