linux-bcachefs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* patch for upgrading to 5.11
@ 2021-03-02 16:00 Janpieter Sollie
  0 siblings, 0 replies; only message in thread
From: Janpieter Sollie @ 2021-03-02 16:00 UTC (permalink / raw)
  To: linux-bcachefs

[-- Attachment #1: Type: text/plain, Size: 413 bytes --]

This patch is a "hack", not a proper solution:

- It contains some things I'm not proud about (eg passing NULL to a function call)

- It contians things I'm not sure of (eg: does fopen need a exclusive lock n the device? or is
read/write sufficient?

Still, it allows me to patch to 5.11 kernel, and so far, everything is OK


Thank you Kent Overstreet for developing this FS!


Kind regards,


Janpieter Sollie


[-- Attachment #2: move_to_5.11.patch --]
[-- Type: text/x-patch, Size: 3112 bytes --]

diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c
index 2b6a300edf1d..1fa87def871e 100644
--- a/fs/bcachefs/fs.c
+++ b/fs/bcachefs/fs.c
@@ -1303,13 +1303,16 @@ static int bch2_sync_fs(struct super_block *sb, int wait)
 	return bch2_journal_flush(&c->journal);
 }
 
-static struct bch_fs *bch2_path_to_fs(const char *dev)
+static struct bch_fs *bch2_path_to_fs(const char *devpath)
 {
 	struct bch_fs *c;
-	struct block_device *bdev = lookup_bdev(dev);
+        struct block_device *bdev;
+        dev_t dev;
+	int err = lookup_bdev(devpath, &dev);
+        bdev = blkdev_get_by_dev(dev, FMODE_READ | FMODE_WRITE, NULL);
 
-	if (IS_ERR(bdev))
-		return ERR_CAST(bdev);
+	if (err)
+		return ERR_PTR(-ENOENT);
 
 	c = bch2_bdev_to_fs(bdev);
 	bdput(bdev);
diff --git a/fs/bcachefs/str_hash.h b/fs/bcachefs/str_hash.h
index 9f0bd4405199..b07294df6a2d 100644
--- a/fs/bcachefs/str_hash.h
+++ b/fs/bcachefs/str_hash.h
@@ -12,7 +12,8 @@
 
 #include <linux/crc32c.h>
 #include <crypto/hash.h>
-#include <crypto/sha.h>
+#include <crypto/sha1.h>
+#include <crypto/sha2.h>
 
 static inline enum bch_str_hash_type
 bch2_str_hash_opt_to_type(struct bch_fs *c, enum bch_str_hash_opts opt)
diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c
index eee7d6c011b6..663ed5e15c51 100644
--- a/fs/bcachefs/super.c
+++ b/fs/bcachefs/super.c
@@ -541,9 +541,8 @@ void __bch2_fs_stop(struct bch_fs *c)
 	for_each_member_device(ca, c, i)
 		if (ca->kobj.state_in_sysfs &&
 		    ca->disk_sb.bdev)
-			sysfs_remove_link(&part_to_dev(ca->disk_sb.bdev->bd_part)->kobj,
+			sysfs_remove_link(&(ca->disk_sb.bdev->bd_device.kobj),
 					  "bcachefs");
-
 	if (c->kobj.state_in_sysfs)
 		kobject_del(&c->kobj);
 
@@ -1005,7 +1004,7 @@ static void bch2_dev_free(struct bch_dev *ca)
 
 	if (ca->kobj.state_in_sysfs &&
 	    ca->disk_sb.bdev)
-		sysfs_remove_link(&part_to_dev(ca->disk_sb.bdev->bd_part)->kobj,
+		sysfs_remove_link(&(ca->disk_sb.bdev->bd_device.kobj),
 				  "bcachefs");
 
 	if (ca->kobj.state_in_sysfs)
@@ -1043,7 +1042,7 @@ static void __bch2_dev_offline(struct bch_fs *c, struct bch_dev *ca)
 
 	if (ca->kobj.state_in_sysfs) {
 		struct kobject *block =
-			&part_to_dev(ca->disk_sb.bdev->bd_part)->kobj;
+			&(ca->disk_sb.bdev->bd_device.kobj);
 
 		sysfs_remove_link(block, "bcachefs");
 		sysfs_remove_link(&ca->kobj, "block");
@@ -1083,7 +1082,7 @@ static int bch2_dev_sysfs_online(struct bch_fs *c, struct bch_dev *ca)
 
 	if (ca->disk_sb.bdev) {
 		struct kobject *block =
-			&part_to_dev(ca->disk_sb.bdev->bd_part)->kobj;
+			&(ca->disk_sb.bdev->bd_device.kobj);
 
 		ret = sysfs_create_link(block, &ca->kobj, "bcachefs");
 		if (ret)
@@ -1817,10 +1816,12 @@ int bch2_dev_resize(struct bch_fs *c, struct bch_dev *ca, u64 nbuckets)
 /* return with ref on ca->ref: */
 struct bch_dev *bch2_dev_lookup(struct bch_fs *c, const char *path)
 {
-	struct block_device *bdev = lookup_bdev(path);
+	struct block_device *bdev;
+	dev_t dev;
 	struct bch_dev *ca;
 	unsigned i;
-
+	int err = lookup_bdev(path, &dev);
+	bdev = blkdev_get_by_dev(dev, FMODE_READ | FMODE_WRITE, NULL);
 	if (IS_ERR(bdev))
 		return ERR_CAST(bdev);
 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-03-03  6:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-02 16:00 patch for upgrading to 5.11 Janpieter Sollie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).