[dovecot-cvs] dovecot/src/lib-index mail-index-data.c,1.41,1.42 mail-index-open.c,1.31,1.32 mail-index-update.c,1.50,1.51 mail-index.h,1.73,1.74
cras at procontrol.fi
cras at procontrol.fi
Sun Apr 27 04:59:45 EEST 2003
Update of /home/cvs/dovecot/src/lib-index
In directory danu:/tmp/cvs-serv23123/src/lib-index
Modified Files:
mail-index-data.c mail-index-open.c mail-index-update.c
mail-index.h
Log Message:
Use separate index alignment from memory alignment. We don't use pointers in
index file so required alignmentation comes pretty much from sizeof(off_t).
Index: mail-index-data.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-data.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- mail-index-data.c 23 Apr 2003 17:07:23 -0000 1.41
+++ mail-index-data.c 27 Apr 2003 00:59:43 -0000 1.42
@@ -449,7 +449,7 @@
{
uoff_t offset;
- i_assert((size & (MEM_ALIGN_SIZE-1)) == 0);
+ i_assert((size & (INDEX_ALIGN_SIZE-1)) == 0);
i_assert(data->index->lock_type == MAIL_LOCK_EXCLUSIVE);
if (!mmap_update(data, 0, sizeof(struct mail_index_data_header)))
@@ -550,7 +550,7 @@
return NULL;
}
- if ((pos % MEM_ALIGN_SIZE) != 0) {
+ if ((pos % INDEX_ALIGN_SIZE) != 0) {
index_data_set_corrupted(data, "Data position (%"PRIuUOFF_T") "
"is not memory aligned for record %u",
pos, index_rec->uid);
@@ -612,7 +612,7 @@
break;
}
- if ((rec->full_field_size % MEM_ALIGN_SIZE) != 0) {
+ if ((rec->full_field_size % INDEX_ALIGN_SIZE) != 0) {
index_data_set_corrupted(data, "Field %d size %u "
"is not memory aligned for record %u",
(int)field, rec->full_field_size,
Index: mail-index-open.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-open.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- mail-index-open.c 23 Apr 2003 16:51:48 -0000 1.31
+++ mail-index-open.c 27 Apr 2003 00:59:43 -0000 1.32
@@ -199,7 +199,7 @@
hdr->compat_data[2] == sizeof(unsigned int) &&
hdr->compat_data[3] == sizeof(time_t) &&
hdr->compat_data[4] == sizeof(uoff_t) &&
- hdr->compat_data[5] == MEM_ALIGN_SIZE;
+ hdr->compat_data[5] == INDEX_ALIGN_SIZE;
}
static int mail_index_init_file(struct mail_index *index,
@@ -235,7 +235,7 @@
hdr->compat_data[2] = sizeof(unsigned int);
hdr->compat_data[3] = sizeof(time_t);
hdr->compat_data[4] = sizeof(uoff_t);
- hdr->compat_data[5] = MEM_ALIGN_SIZE;
+ hdr->compat_data[5] = INDEX_ALIGN_SIZE;
hdr->indexid = ioloop_time;
/* mark the index requiring rebuild - rebuild() removes this flag
Index: mail-index-update.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-update.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- mail-index-update.c 26 Mar 2003 17:29:02 -0000 1.50
+++ mail-index-update.c 27 Apr 2003 00:59:43 -0000 1.51
@@ -81,11 +81,11 @@
if (update->fields[i] != NULL) {
/* value was modified - use it */
- field_min_size = MEM_ALIGN(update->field_sizes[i]);
+ field_min_size = INDEX_ALIGN(update->field_sizes[i]);
*min_size += SIZEOF_MAIL_INDEX_DATA + field_min_size;
*max_size += SIZEOF_MAIL_INDEX_DATA +
- MEM_ALIGN(update->field_sizes[i] +
- update->field_extra_sizes[i]);
+ INDEX_ALIGN(update->field_sizes[i] +
+ update->field_extra_sizes[i]);
if (!field_exists ||
rec->full_field_size < field_min_size)
@@ -109,15 +109,15 @@
{
size_t size;
- size = MEM_ALIGN(base);
+ size = INDEX_ALIGN(base);
extra -= size - base;
- if (*max_extra < MEM_ALIGN_SIZE || extra == 0)
+ if (*max_extra < INDEX_ALIGN_SIZE || extra == 0)
return size; /* no extra / extra went into alignment */
- extra = MEM_ALIGN(extra);
+ extra = INDEX_ALIGN(extra);
if (extra > *max_extra) {
/* partial */
- extra = *max_extra & ~(size_t)(MEM_ALIGN_SIZE-1);
+ extra = *max_extra & ~(size_t)(INDEX_ALIGN_SIZE-1);
i_assert(extra <= *max_extra);
}
@@ -168,7 +168,7 @@
/* the field doesn't exist, jump to next */
continue;
}
- i_assert((full_field_size % MEM_ALIGN_SIZE) == 0);
+ i_assert((full_field_size % INDEX_ALIGN_SIZE) == 0);
destrec = buffer_append_space(buf, SIZEOF_MAIL_INDEX_DATA +
full_field_size);
Index: mail-index.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index.h,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- mail-index.h 21 Apr 2003 13:42:00 -0000 1.73
+++ mail-index.h 27 Apr 2003 00:59:43 -0000 1.74
@@ -118,7 +118,7 @@
2 = sizeof(unsigned int),
3 = sizeof(time_t),
4 = sizeof(uoff_t),
- 5 = MEM_ALIGN_SIZE */
+ 5 = INDEX_ALIGN_SIZE */
unsigned int indexid;
unsigned int sync_id; /* re-mmap() when changed, required only
@@ -176,11 +176,11 @@
struct mail_index_data_record {
unsigned int field; /* enum mail_data_field */
unsigned int full_field_size;
- char data[MEM_ALIGN_SIZE]; /* variable size */
+ char data[INDEX_ALIGN_SIZE]; /* variable size */
};
#define SIZEOF_MAIL_INDEX_DATA \
- (sizeof(struct mail_index_data_record) - MEM_ALIGN_SIZE)
+ (sizeof(struct mail_index_data_record) - INDEX_ALIGN_SIZE)
#define DATA_RECORD_SIZE(rec) \
(SIZEOF_MAIL_INDEX_DATA + (rec)->full_field_size)
@@ -348,7 +348,7 @@
void (*update_field)(struct mail_index_update *update,
enum mail_data_field field,
const char *value, size_t extra_space);
- /* Just remember that full_field_size will be MEM_ALIGNed, so
+ /* Just remember that full_field_size will be INDEX_ALIGNed, so
it may differer from the given size parameter. */
void (*update_field_raw)(struct mail_index_update *update,
enum mail_data_field field,
@@ -590,5 +590,9 @@
#define INDEX_IS_IN_MEMORY(index) \
((index)->anon_mmap)
+
+/* Returns alignmentation for given size */
+#define INDEX_ALIGN(size) \
+ (((size) + INDEX_ALIGN_SIZE-1) & ~((unsigned int) INDEX_ALIGN_SIZE-1))
#endif
More information about the dovecot-cvs
mailing list