Re: [PATCH v2 3/3] vfs: Use per-cpu list for superblock's inode list

From: Waiman Long
Date: Tue Feb 23 2016 - 13:57:13 EST


On 02/21/2016 04:34 PM, Dave Chinner wrote:
On Fri, Feb 19, 2016 at 04:10:45PM -0500, Waiman Long wrote:
+/*
+ * Superblock's inode list iterator function and arguments macros
+ */
+#define SB_INODES_ITER_FUNC(name, lock, struct_fields) \
+ struct name ## _arg { \
+ struct_fields; \
+ }; \
+ static int name ## _iter(struct pcpu_list_node *_node, \
+ struct pcpu_list_node **_pnext, \
+ spinlock_t *lock, void *_arg)
+
+#define SB_INODES_ITER_ARGS(name, i, a) \
+ struct inode *i = container_of(_node, struct inode, i_sb_list); \
+ struct name ## _arg *a = (struct name ## _arg *)_arg
+
+#define SB_INODES_ITER_ARGS_SAFE(name, i, n, a) \
+ struct inode *i = container_of(_node, struct inode, i_sb_list); \
+ struct inode *n = container_of(*_pnext, struct inode, i_sb_list);\
+ struct name ## _arg *a = (struct name ## _arg *)_arg
+
+#define SB_INODES_ITER_SET_PCPU_LIST_NEXT(n) \
+ { *_pnext =&(n)->i_sb_list; }
+
+#define SB_INODES_ITER_CALL(name, sb) \
+ pcpu_list_iterate(sb->s_inodes, false, NULL, name ## _iter,&arg)
+
+#define SB_INODES_ITER_CALL_SAFE(name, sb, phead) \
+ pcpu_list_iterate(sb->s_inodes, true, phead, name ## _iter,&arg)
+
No, just no.

Ungreppable, breaks cscope, obfuscates everything, shouts a lot,
code using the API looks completely broken (e.g. semi-colons in
"function declarations"), and it reminds me of the worst of the
worst unmaintainable code in an exceedingly buggy and undebuggable
proprietary filesystem I've previously had the "joy" of working
with.

Just fix the bug in the previous version; it's so much cleaner than
this .... mess.

Cheers,

Dave.

Sorry for that. I will scrap the current approach and use another way to iterate the list instead. I will send out an updated patch soon.

Cheers,
Longman