<commit_before>#include <linux/slab.h>
#include <linux/mempool.h>
#include <linux/bio.h>
#include <linux/interrupt.h>
#include <linux/timer.h>
#include <linux/wait.h>
#include "convergent.h"

/* XXX rename all this */

enum cd_bits {
	__CD_USER,           /* Was given to userspace; waiting for reply */
	__CD_NR_BITS
};

#define CD_USER         (1 << __CD_USER)

enum cd_state {
	ST_INVALID,          /* No key or data */
	ST_LOAD_META,        /* Loading metadata */
	ST_META,             /* Have metadata but not data */
	ST_LOAD_DATA,        /* Loading data */
	ST_CLEAN,            /* Have metadata and data */
	ST_DIRTY,            /* Data is dirty */
	ST_STORE_DATA,       /* Storing data */
	ST_DIRTY_META,       /* Metadata is dirty */
	ST_STORE_META,       /* Storing metadata */
	ST_ERROR,            /* I/O error occurred; data not valid */
	NR_STATES
};

struct chunkdata {
	struct list_head lh_bucket;
	struct list_head lh_lru;
	struct list_head lh_user;
	struct list_head lh_need_update;
	struct chunkdata_table *table;
	chunk_t cid;
	unsigned size;         /* compressed size before padding */
	compress_t compression;/* compression type */
	struct list_head pending;
	atomic_t remaining;    /* bytes, for I/O */
	int error;
	struct work_struct cb_complete_io;
	unsigned flags;
	enum cd_state state;
	char key[ISR_MAX_HASH_LEN];
	struct scatterlist *sg;
};

struct chunkdata_table {
	struct convergent_dev *dev;
	unsigned buckets;
	unsigned state_count[NR_STATES];
	unsigned busy_count;
	struct list_head lru;
	struct list_head user;
	struct list_head need_update;
	struct list_head *hash;
	struct work_struct cb_run_chunks;
};

static struct bio_set *bio_pool;


static unsigned hash(struct chunkdata_table *table, chunk_t cid)
{
	return cid % table->buckets;
}

static inline struct convergent_io_chunk *pending_head(struct chunkdata *cd)
{
	if (list_empty(&cd->pending))
		return NULL;
	return list_entry(cd->pending.next, struct convergent_io_chunk,
					lh_pending);
}

static inline int pending_head_is(struct chunkdata *cd,
			struct convergent_io_chunk *chunk)<commit_msg>r170: - Fix compile failure with CONFIG_LBD: 64-bit divs and mods aren't allowed in the kernel on a 32-bit platform.  In this case, we only care about the low bits anyway.<commit_after>#include <linux/slab.h>
#include <linux/mempool.h>
#include <linux/bio.h>
#include <linux/interrupt.h>
#include <linux/timer.h>
#include <linux/wait.h>
#include "convergent.h"

/* XXX rename all this */

enum cd_bits {
	__CD_USER,           /* Was given to userspace; waiting for reply */
	__CD_NR_BITS
};

#define CD_USER         (1 << __CD_USER)

enum cd_state {
	ST_INVALID,          /* No key or data */
	ST_LOAD_META,        /* Loading metadata */
	ST_META,             /* Have metadata but not data */
	ST_LOAD_DATA,        /* Loading data */
	ST_CLEAN,            /* Have metadata and data */
	ST_DIRTY,            /* Data is dirty */
	ST_STORE_DATA,       /* Storing data */
	ST_DIRTY_META,       /* Metadata is dirty */
	ST_STORE_META,       /* Storing metadata */
	ST_ERROR,            /* I/O error occurred; data not valid */
	NR_STATES
};

struct chunkdata {
	struct list_head lh_bucket;
	struct list_head lh_lru;
	struct list_head lh_user;
	struct list_head lh_need_update;
	struct chunkdata_table *table;
	chunk_t cid;
	unsigned size;         /* compressed size before padding */
	compress_t compression;/* compression type */
	struct list_head pending;
	atomic_t remaining;    /* bytes, for I/O */
	int error;
	struct work_struct cb_complete_io;
	unsigned flags;
	enum cd_state state;
	char key[ISR_MAX_HASH_LEN];
	struct scatterlist *sg;
};

struct chunkdata_table {
	struct convergent_dev *dev;
	unsigned buckets;
	unsigned state_count[NR_STATES];
	unsigned busy_count;
	struct list_head lru;
	struct list_head user;
	struct list_head need_update;
	struct list_head *hash;
	struct work_struct cb_run_chunks;
};

static struct bio_set *bio_pool;


static unsigned hash(struct chunkdata_table *table, chunk_t cid)
{
	return (unsigned)cid % table->buckets;
}

static inline struct convergent_io_chunk *pending_head(struct chunkdata *cd)
{
	if (list_empty(&cd->pending))
		return NULL;
	return list_entry(cd->pending.next, struct convergent_io_chunk,
					lh_pending);
}

static inline int pending_head_is(struct chunkdata *cd,
			struct convergent_io_chunk *chunk)
{'fraction_non_alphanumeric': 0.09522716842588343, 'fraction_numerical': 0.002065167508031207, 'mean_word_length': 3.5170984455958547, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7449229', 'n_tokens_mistral': 1514, 'n_tokens_neox': 1470, 'n_words': 420}