Skip to contentSkip to conversation

Btrfs: simplify iteration codes

PATCH Superseded Qinghuang Feng 3 participants 5 messages Jan 16, 2009 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Btrfs: simplify iteration codes

merge list_for_each and list_entry to list_for_each_entry.

---

fs/btrfs/volumes.c +2 -6
index b187b53..70f0248 100644
@@ -104,10 +104,8 @@ static noinline struct btrfs_device *__find_device(struct list_head *head,
 						   u64 devid, u8 *uuid)
 {
 	struct btrfs_device *dev;
-	struct list_head *cur;
 
-	list_for_each(cur, head) {
-		dev = list_entry(cur, struct btrfs_device, dev_list);
+	list_for_each_entry(dev, head, dev_list) {
 		if (dev->devid == devid &&
 		    (!uuid || !memcmp(dev->uuid, uuid, BTRFS_UUID_SIZE))) {
 			return dev;
@@ -118,11 +116,9 @@ static noinline struct btrfs_device *__find_device(struct list_head *head,
 
 static noinline struct btrfs_fs_devices *find_fsid(u8 *fsid)
 {
-	struct list_head *cur;
 	struct btrfs_fs_devices *fs_devices;
 
-	list_for_each(cur, &fs_uuids) {
-		fs_devices = list_entry(cur, struct btrfs_fs_devices, list);
+	list_for_each_entry(fs_devices, &fs_uuids, list) {
 		if (memcmp(fsid, fs_devices->fsid, BTRFS_FSID_SIZE) == 0)
 			return fs_devices;
 	}
#1 lore raw
Quoted 2 lines · Qinghuang Feng

merge list_for_each and list_entry to list_for_each_entry.

Please ignore this patch, I will resend a patch to cleanup all the similar codes in btrfs.

#3 lore raw
Quoted 6 lines · Chris Mason
Quoted 2 lines · Qinghuang Feng

merge list_for_each and list_entry to list_for_each_entry.

Thanks, I've queued this up.

Good, but....

Now I have made a new patch for cleanupping all the similar codes in btrfs. This patch has been tested in VM, it seems ok.

Now should I rebuild another patch which based the previous patch, or could you be able to reverse the previous patch then I just post this new patch including all stuff?

Sorry I am not much familiar with the posting flow, and I am not sure the meaning of "queued".

#4 lore raw
Quoted 12 lines · sniper
Quoted 6 lines · Chris Mason
Quoted 2 lines · Qinghuang Feng

merge list_for_each and list_entry to list_for_each_entry.

Thanks, I've queued this up.

Good, but....

Now I have made a new patch for cleanupping all the similar codes in btrfs. This patch has been tested in VM, it seems ok.

Quoted 6 lines

Now should I rebuild another patch which based the previous patch, or could you be able to reverse the previous patch then I just post this new patch including all stuff?

Sorry I am not much familiar with the posting flow, and I am not sure the meaning of "queued".

It means this one looks right and I've put it into my internal testing tree. It should be in my next pull request.

But, I'll hold off on this one if there is a larger set of fixes coming that contain it.

-chris