diff --git a/kmod/src/Makefile.kernelcompat b/kmod/src/Makefile.kernelcompat index 39210f32..849db059 100644 --- a/kmod/src/Makefile.kernelcompat +++ b/kmod/src/Makefile.kernelcompat @@ -267,3 +267,11 @@ endif ifneq (,$(shell grep 'typedef __u32 __bitwise blk_opf_t' include/linux/blk_types.h)) ccflags-y += -DKC_HAVE_BLK_OPF_T=1 endif + +# +# v5.12-rc6-9-g4f0f586bf0c8 +# +# list_sort cmp function takes const list_head args +ifneq (,$(shell grep 'const struct list_head ., const struct list_head .' include/linux/list_sort.h)) +ccflags-y += -DKC_LIST_CMP_CONST_ARG_LIST_HEAD +endif diff --git a/kmod/src/inode.c b/kmod/src/inode.c index 2203a8e9..04c088c2 100644 --- a/kmod/src/inode.c +++ b/kmod/src/inode.c @@ -979,10 +979,10 @@ static bool inode_has_index(umode_t mode, u8 type) } } -static int cmp_index_lock(void *priv, struct list_head *A, struct list_head *B) +static int cmp_index_lock(void *priv, KC_LIST_CMP_CONST struct list_head *A, KC_LIST_CMP_CONST struct list_head *B) { - struct index_lock *a = list_entry(A, struct index_lock, head); - struct index_lock *b = list_entry(B, struct index_lock, head); + KC_LIST_CMP_CONST struct index_lock *a = list_entry(A, KC_LIST_CMP_CONST struct index_lock, head); + KC_LIST_CMP_CONST struct index_lock *b = list_entry(B, KC_LIST_CMP_CONST struct index_lock, head); return ((int)a->type - (int)b->type) ?: scoutfs_cmp_u64s(a->major, b->major) ?: diff --git a/kmod/src/item.c b/kmod/src/item.c index 9ec5aad0..f7691e6e 100644 --- a/kmod/src/item.c +++ b/kmod/src/item.c @@ -2241,18 +2241,18 @@ u64 scoutfs_item_dirty_pages(struct super_block *sb) return (u64)atomic_read(&cinf->dirty_pages); } -static int cmp_pg_start(void *priv, struct list_head *A, struct list_head *B) +static int cmp_pg_start(void *priv, KC_LIST_CMP_CONST struct list_head *A, KC_LIST_CMP_CONST struct list_head *B) { - struct cached_page *a = list_entry(A, struct cached_page, dirty_head); - struct cached_page *b = list_entry(B, struct cached_page, dirty_head); + KC_LIST_CMP_CONST struct cached_page *a = list_entry(A, KC_LIST_CMP_CONST struct cached_page, dirty_head); + KC_LIST_CMP_CONST struct cached_page *b = list_entry(B, KC_LIST_CMP_CONST struct cached_page, dirty_head); return scoutfs_key_compare(&a->start, &b->start); } -static int cmp_item_key(void *priv, struct list_head *A, struct list_head *B) +static int cmp_item_key(void *priv, KC_LIST_CMP_CONST struct list_head *A, KC_LIST_CMP_CONST struct list_head *B) { - struct cached_item *a = list_entry(A, struct cached_item, dirty_head); - struct cached_item *b = list_entry(B, struct cached_item, dirty_head); + KC_LIST_CMP_CONST struct cached_item *a = list_entry(A, KC_LIST_CMP_CONST struct cached_item, dirty_head); + KC_LIST_CMP_CONST struct cached_item *b = list_entry(B, KC_LIST_CMP_CONST struct cached_item, dirty_head); return scoutfs_key_compare(&a->key, &b->key); } diff --git a/kmod/src/kernelcompat.h b/kmod/src/kernelcompat.h index 6f2a8b07..54377d56 100644 --- a/kmod/src/kernelcompat.h +++ b/kmod/src/kernelcompat.h @@ -278,4 +278,10 @@ ssize_t kc_generic_file_buffered_write(struct kiocb *iocb, const struct iovec *i typedef unsigned int blk_opf_t; #endif +#ifdef KC_LIST_CMP_CONST_ARG_LIST_HEAD +#define KC_LIST_CMP_CONST const +#else +#define KC_LIST_CMP_CONST +#endif + #endif diff --git a/kmod/src/key.h b/kmod/src/key.h index 66a4c84a..cd1e7710 100644 --- a/kmod/src/key.h +++ b/kmod/src/key.h @@ -125,8 +125,8 @@ static inline bool scoutfs_key_is_ones(struct scoutfs_key *key) * other alternatives across keys that first differ in any of the * values. Say maybe 20% faster than memcmp. */ -static inline int scoutfs_key_compare(struct scoutfs_key *a, - struct scoutfs_key *b) +static inline int scoutfs_key_compare(const struct scoutfs_key *a, + const struct scoutfs_key *b) { return scoutfs_cmp(a->sk_zone, b->sk_zone) ?: scoutfs_cmp(le64_to_cpu(a->_sk_first), le64_to_cpu(b->_sk_first)) ?: @@ -142,10 +142,10 @@ static inline int scoutfs_key_compare(struct scoutfs_key *a, * 1: a_start > b_end * else 0: ranges overlap */ -static inline int scoutfs_key_compare_ranges(struct scoutfs_key *a_start, - struct scoutfs_key *a_end, - struct scoutfs_key *b_start, - struct scoutfs_key *b_end) +static inline int scoutfs_key_compare_ranges(const struct scoutfs_key *a_start, + const struct scoutfs_key *a_end, + const struct scoutfs_key *b_start, + const struct scoutfs_key *b_end) { return scoutfs_key_compare(a_end, b_start) < 0 ? -1 : scoutfs_key_compare(a_start, b_end) > 0 ? 1 : diff --git a/kmod/src/recov.c b/kmod/src/recov.c index 78123e27..d77e39cf 100644 --- a/kmod/src/recov.c +++ b/kmod/src/recov.c @@ -76,10 +76,10 @@ static struct recov_pending *lookup_pending(struct recov_info *recinf, u64 rid, * We keep the pending list sorted by rid so that we can iterate over * them. The list should be small and shouldn't be used often. */ -static int cmp_pending_rid(void *priv, struct list_head *A, struct list_head *B) +static int cmp_pending_rid(void *priv, KC_LIST_CMP_CONST struct list_head *A, KC_LIST_CMP_CONST struct list_head *B) { - struct recov_pending *a = list_entry(A, struct recov_pending, head); - struct recov_pending *b = list_entry(B, struct recov_pending, head); + KC_LIST_CMP_CONST struct recov_pending *a = list_entry(A, KC_LIST_CMP_CONST struct recov_pending, head); + KC_LIST_CMP_CONST struct recov_pending *b = list_entry(B, KC_LIST_CMP_CONST struct recov_pending, head); return scoutfs_cmp_u64s(a->rid, b->rid); }