CHROMIUM: remove sysctl vm.disk_based_swap

This is unnecessary deviation w.r.t. upstream linux. The config option
CONFIG_DISK_BASED_SWAP is enough to enable/disable the swap support.

BUG=b:62107328
TEST=trybots

Change-Id: I787c706b677408f2954b74a7309aab6fbb90c58f
Reviewed-on: https://chromium-review.googlesource.com/535873
Commit-Ready: Aditya Kali <adityakali@google.com>
Tested-by: Aditya Kali <adityakali@google.com>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 1ae84b7..2e4c49a 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2334,9 +2334,5 @@
 static inline void setup_nr_node_ids(void) {}
 #endif
 
-#ifdef CONFIG_DISK_BASED_SWAP
-extern int sysctl_disk_based_swap;
-#endif
-
 #endif /* __KERNEL__ */
 #endif /* _LINUX_MM_H */
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 81fa7c1..9545f7f 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1692,17 +1692,6 @@
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec,
 	},
-#ifdef CONFIG_DISK_BASED_SWAP
-	{
-		.procname	= "disk_based_swap",
-		.data		= &sysctl_disk_based_swap,
-		.maxlen		= sizeof(sysctl_disk_based_swap),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec_minmax,
-		.extra1		= &zero,
-		.extra2		= &one,
-	},
-#endif
 	{ }
 };
 
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 23ce2c4..eb1c327 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -2195,11 +2195,7 @@
 	return p;
 }
 
-/* This sysctl is only exposed when CONFIG_DISK_BASED_SWAP is enabled. */
-int sysctl_disk_based_swap;
-
-static int claim_swapfile(struct swap_info_struct *p, struct inode *inode,
-			  bool allow_disk_based_swap)
+static int claim_swapfile(struct swap_info_struct *p, struct inode *inode)
 {
 	int error;
 	/* On Chromium OS, we only support zram swap devices. */
@@ -2223,7 +2219,8 @@
 		if (error < 0)
 			return error;
 		p->flags |= SWP_BLKDEV;
-	} else if (S_ISREG(inode->i_mode) && allow_disk_based_swap) {
+	} else if (S_ISREG(inode->i_mode) &&
+		   IS_ENABLED(CONFIG_DISK_BASED_SWAP)) {
 		p->bdev = inode->i_sb->s_bdev;
 		mutex_lock(&inode->i_mutex);
 		if (IS_SWAPFILE(inode))
@@ -2430,7 +2427,6 @@
 	unsigned long *frontswap_map = NULL;
 	struct page *page = NULL;
 	struct inode *inode = NULL;
-	bool allow_disk_based_swap = sysctl_disk_based_swap ? true : false;
 
 	if (swap_flags & ~SWAP_FLAGS_VALID)
 		return -EINVAL;
@@ -2462,7 +2458,7 @@
 	inode = mapping->host;
 
 	/* If S_ISREG(inode->i_mode) will do mutex_lock(&inode->i_mutex); */
-	error = claim_swapfile(p, inode, allow_disk_based_swap);
+	error = claim_swapfile(p, inode);
 	if (unlikely(error))
 		goto bad_swap;
 
@@ -2606,7 +2602,7 @@
 	vfree(cluster_info);
 	if (swap_file) {
 		if (inode && S_ISREG(inode->i_mode)) {
-			if (allow_disk_based_swap)
+			if (IS_ENABLED(CONFIG_DISK_BASED_SWAP))
 				mutex_unlock(&inode->i_mutex);
 			inode = NULL;
 		}