1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-02-24 17:57:48 +03:00

o Error list handling now part of fs rather than part of table.

This commit is contained in:
Steven Whitehouse 2001-10-24 08:26:10 +00:00
parent 6215194e2b
commit 64b6e4e4b3
6 changed files with 33 additions and 26 deletions

View File

@ -114,7 +114,6 @@ struct dm_table *dm_table_create(void)
memset(t, 0, sizeof(*t));
INIT_LIST_HEAD(&t->devices);
INIT_LIST_HEAD(&t->errors);
/* allocate a single nodes worth of targets to
begin with */
@ -141,8 +140,6 @@ void dm_table_destroy(struct dm_table *t)
{
int i;
dmfs_zap_errors(t);
/* free the indexes (see dm_table_complete) */
if (t->depth >= 2)
vfree(t->index[t->depth - 2]);

View File

@ -178,8 +178,6 @@ struct dm_table {
/* a list of devices used by this table */
struct list_head devices;
struct list_head errors;
};
/*
@ -208,6 +206,7 @@ struct dmfs_i {
struct dm_table *table;
struct mapped_device *md;
struct dentry *dentry;
struct list_head errors;
};
#define DMFS_I(inode) ((struct dmfs_i *)(inode)->u.generic_ip)
@ -241,8 +240,8 @@ int dm_table_add_target(struct dm_table *t, offset_t high,
int dm_table_complete(struct dm_table *t);
/* dmfs-error.c */
void dmfs_add_error(struct dm_table *t, unsigned num, char *str);
void dmfs_zap_errors(struct dm_table *t);
void dmfs_add_error(struct inode *inode, unsigned num, char *str);
void dmfs_zap_errors(struct inode *inode);
/* dmfs-super.c */
struct super_block *dmfs_read_super(struct super_block *, void *, int);

View File

@ -31,34 +31,36 @@ struct dmfs_error {
char *msg;
};
void dmfs_add_error(struct dm_table *t, unsigned num, char *str)
void dmfs_add_error(struct inode *inode, unsigned num, char *str)
{
struct dmfs_i *dmi = DMFS_I(inode);
int len = strlen(str) + sizeof(struct dmfs_error) + 12;
struct dmfs_error *e = kmalloc(len, GFP_KERNEL);
if (e) {
e->msg = (char *)(e + 1);
e->len = sprintf(e->msg, "%8u: %s\n", num, str);
list_add(&e->list, &t->errors);
list_add(&e->list, &dmi->errors);
}
}
void dmfs_zap_errors(struct dm_table *t)
void dmfs_zap_errors(struct inode *inode)
{
struct dmfs_i *dmi = DMFS_I(inode);
struct dmfs_error *e;
while(!list_empty(&t->errors)) {
e = list_entry(t->errors.next, struct dmfs_error, list);
while(!list_empty(&dmi->errors)) {
e = list_entry(dmi->errors.next, struct dmfs_error, list);
list_del(&e->list);
kfree(e);
}
}
static struct dmfs_error *find_initial_message(struct dm_table *t, loff_t *pos)
static struct dmfs_error *find_initial_message(struct inode *inode, loff_t *pos)
{
struct dmfs_error *e;
struct list_head *tmp, *head;
tmp = head = &t->errors;
tmp = head = &DMFS_I(inode)->errors;
for(;;) {
tmp = tmp->next;
if (tmp == head)
@ -72,7 +74,7 @@ static struct dmfs_error *find_initial_message(struct dm_table *t, loff_t *pos)
return NULL;
}
static int copy_sequence(struct dm_table *t, struct dmfs_error *e, char *buf,
static int copy_sequence(struct inode *inode, struct dmfs_error *e, char *buf,
size_t size, loff_t offset)
{
char *from;
@ -94,7 +96,7 @@ static int copy_sequence(struct dm_table *t, struct dmfs_error *e, char *buf,
size -= amount;
offset = 0;
if (e->list.next == &t->errors)
if (e->list.next == &DMFS_I(inode)->errors)
break;
e = list_entry(e->list.next, struct dmfs_error, list);
} while(size > 0);
@ -104,7 +106,8 @@ static int copy_sequence(struct dm_table *t, struct dmfs_error *e, char *buf,
static ssize_t dmfs_error_read(struct file *file, char *buf, size_t size, loff_t *pos)
{
struct dmfs_i *dmi = DMFS_I(file->f_dentry->d_parent->d_inode);
struct inode *inode = file->f_dentry->d_parent->d_inode;
struct dmfs_i *dmi = DMFS_I(inode);
struct dm_table *t = dmi->table;
int copied = 0;
loff_t offset = *pos;
@ -114,9 +117,9 @@ static ssize_t dmfs_error_read(struct file *file, char *buf, size_t size, loff_t
down(&dmi->sem);
if (dmi->table) {
struct dmfs_error *e = find_initial_message(t, &offset);
struct dmfs_error *e = find_initial_message(inode, &offset);
if (e) {
copied = copy_sequence(t, e, buf, size, offset);
copied = copy_sequence(inode, e, buf, size, offset);
if (copied > 0)
(*pos) += copied;
}

View File

@ -58,7 +58,7 @@ struct dentry *dmfs_verify_name(struct inode *dir, const char *name)
DMFS_I(nd.dentry->d_inode)->table == NULL)
goto err_out;
if (!list_empty(&(DMFS_I(nd.dentry->d_inode)->table->errors)))
if (!list_empty(&(DMFS_I(nd.dentry->d_inode)->errors)))
goto err_out;
dentry = nd.dentry;

View File

@ -48,6 +48,8 @@ static void dmfs_delete_inode(struct inode *inode)
dm_table_destroy(dmi->table);
if (dmi->dentry)
dput(dmi->dentry);
if (!list_empty(&dmi->errors))
dmfs_zap_errors(inode);
kfree(dmi);
}
@ -106,6 +108,7 @@ struct inode *dmfs_new_inode(struct super_block *sb, int mode)
}
memset(dmi, 0, sizeof(struct dmfs_i));
init_MUTEX(&dmi->sem);
INIT_LIST_HEAD(&dmi->errors);
inode->u.generic_ip = dmi;
}
return inode;

View File

@ -34,7 +34,7 @@ static offset_t start_of_next_range(struct dm_table *t)
return n;
}
static void dmfs_parse_line(struct dm_table *t, unsigned num, char *str)
static char *dmfs_parse_line(struct dm_table *t, char *str)
{
offset_t start, size, high;
void *context;
@ -77,13 +77,13 @@ static char *err_table[] = {
msg = "Error adding target to table";
high = start + (size - 1);
if (dm_table_add_target(t, high, ttype, context) == 0)
return;
return NULL;
ttype->dtr(t, context);
}
dm_put_target_type(ttype);
}
out:
dmfs_add_error(t, num, msg);
return msg;
}
@ -128,7 +128,7 @@ struct dmfs_desc {
static int dmfs_read_actor(read_descriptor_t *desc, struct page *page, unsigned long offset, unsigned long size)
{
char *buf;
char *buf, *msg;
unsigned long count = desc->count, len, copied;
struct dmfs_desc *d = (struct dmfs_desc *)desc->buf;
@ -148,8 +148,12 @@ static int dmfs_read_actor(read_descriptor_t *desc, struct page *page, unsigned
d->tmpl += copied;
if (flag || (len == 0 && count == size)) {
*(d->tmp + d->tmpl) = 0;
if (dmfs_line_is_not_comment(d->tmp))
dmfs_parse_line(d->table, d->lnum, d->tmp);
if (dmfs_line_is_not_comment(d->tmp)) {
msg = dmfs_parse_line(d->table, d->tmp);
if (msg) {
dmfs_add_error(t, d->lnum, msg);
}
}
d->lnum++;
d->tmpl = 0;
}
@ -212,6 +216,7 @@ static int dmfs_table_release(struct inode *inode, struct file *f)
if (f->f_mode & FMODE_WRITE) {
down(&dmi->sem);
dmfs_zap_errors(dentry->d_parent->d_inode);
table = dmfs_parse(dentry->d_parent->d_inode, f);
if (table) {