Skip to content
Snippets Groups Projects
Commit 59e67430 authored by Peter Braam's avatar Peter Braam
Browse files

things are starting to work for Linux 2.4.2!!

ext2obd works (except _write and _read which aren't that important).
parent a86aaafa
No related branches found
No related tags found
No related merge requests found
......@@ -3,18 +3,18 @@
struct obd_conn_info {
unsigned int conn_id; /* handle */
unsigned int conn_id; /* handle */
};
struct obd_type {
struct list_head typ_chain;
struct obd_ops *typ_ops;
char *typ_name;
int typ_refcnt;
struct list_head typ_chain;
struct obd_ops *typ_ops;
char *typ_name;
int typ_refcnt;
};
#define OBD_MAGIC 0xffff0000
#define OBD_MAGIC_MASK 0xffff0000
#define OBD_MAGIC 0xffff0000
#define OBD_MAGIC_MASK 0xffff0000
......
This diff is collapsed.
......@@ -10,7 +10,7 @@
#endif
struct ext2_obd {
struct super_block * ext2_sb;
struct super_block * ext2_sb;
};
......@@ -29,8 +29,8 @@ void ext2_free_blocks (const struct inode * inode, unsigned long block,
unsigned long ext2_count_free_blocks (struct super_block * sb);
int ext2_group_sparse(int group);
struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
unsigned int block_group,
struct buffer_head ** bh);
unsigned int block_group,
struct buffer_head ** bh);
/* bitmap.c */
unsigned long ext2_count_free(struct buffer_head * map, unsigned int numchars);
......@@ -43,19 +43,19 @@ extern struct file_operations ext2_file_operations;
extern struct inode_operations ext2_file_inode_operations;
/* fsync.c */
int ext2_sync_file(struct file * file, struct dentry *dentry);
int ext2_sync_file(struct file * file, struct dentry *dentry, int);
/* ialloc.c */
void ext2_free_inode (struct inode * inode);
struct inode * ext2_new_inode (const struct inode * dir, int mode,
int * err);
struct inode * ext2_new_inode (const struct inode * dir, int );
unsigned long ext2_count_free_inodes (struct super_block * sb);
void ext2_check_inodes_bitmap (struct super_block * sb);
int load_inode_bitmap (struct super_block * sb,
unsigned int block_group);
unsigned int block_group);
/* inode.c */
inline long ext2_block_map (struct inode * inode, long block);
int ext2_bmap(struct address_space *mapping, long block);
int ext2_get_block(struct inode *inode, long iblock, struct buffer_head *bh_result, int create);
/* super.c */
......@@ -76,25 +76,10 @@ inline long ext2_block_map (struct inode * inode, long block);
extern struct super_operations ext2_sops;
int obd_remount (struct super_block * sb, int * flags, char * data);
struct super_block * ext2_read_super (struct super_block * sb, void * data,
int silent);
int silent);
/* punch.c */
void ext2_truncate (struct inode * inode);
int ext2_punch (struct inode * inode, loff_t start, size_t count);
static inline struct page *addr_to_page(char *buf)
{
unsigned long addr = (unsigned long)buf;
unsigned long map_nr;
#ifdef CONFIG_DISCONTIGMEM
if (addr == 0) return;
#endif
map_nr = MAP_NR(addr);
if (map_nr < max_mapnr)
return mem_map + map_nr;
else
return 0;
}
#endif
......@@ -10,12 +10,12 @@
#endif
struct raid1_obd {
unsigned int raid1_count; /* how many replicas */
/* devices to replicate on */
struct obd_device *raid1_devlist[MAX_RAID1];
/* connections we make */
struct obd_conn_info raid1_connections[MAX_RAID1];
struct list_head raid1_clients; /* clients we have */
unsigned int raid1_count; /* how many replicas */
/* devices to replicate on */
struct obd_device *raid1_devlist[MAX_RAID1];
/* connections we make */
struct obd_conn_info raid1_connections[MAX_RAID1];
struct list_head raid1_clients; /* clients we have */
};
......@@ -35,8 +35,8 @@ void ext2_free_blocks (const struct inode * inode, unsigned long block,
unsigned long ext2_count_free_blocks (struct super_block * sb);
int ext2_group_sparse(int group);
struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
unsigned int block_group,
struct buffer_head ** bh);
unsigned int block_group,
struct buffer_head ** bh);
/* bitmap.c */
unsigned long ext2_count_free(struct buffer_head * map, unsigned int numchars);
......@@ -46,12 +46,11 @@ extern int obd_sync_file(struct file * file, struct dentry *dentry);
/* ialloc.c */
extern void ext2_free_inode (struct inode * inode);
extern struct inode * ext2_new_inode (const struct inode * dir, int mode,
int * err);
extern struct inode * ext2_new_inode (const struct inode * dir, int mode);
extern unsigned long ext2_count_free_inodes (struct super_block * sb);
extern void ext2_check_inodes_bitmap (struct super_block * sb);
extern int load_inode_bitmap (struct super_block * sb,
unsigned int block_group);
unsigned int block_group);
/* inode.c */
void obd_read_inode (struct inode * inode);
......@@ -68,7 +67,7 @@ struct buffer_head * obd_getblk (struct inode * inode, long block,
int obd_remount (struct super_block * sb, int * flags, char * data);
struct super_block * ext2_read_super (struct super_block * sb, void * data,
int silent);
int silent);
/* truncate.c */
void obd_truncate (struct inode * inode);
......
#ifndef __OBD_RPC_H
#define __OBD_RPC_H
#include <linux/sunrpc/svc.h>
#define OBD_TGT_VERSION 001
#define OBD_TGT_TCP 0x1
......@@ -35,42 +36,42 @@ extern struct rpc_program obd_program;
struct obd_target {
struct sockaddr_in tgt_addr;
int tgt_flags;
int tgt_timeo;
int tgt_retrans;
int tgt_hostnamelen;
char tgt_hostname[0];
struct sockaddr_in tgt_addr;
int tgt_flags;
int tgt_timeo;
int tgt_retrans;
int tgt_hostnamelen;
char tgt_hostname[0];
};
struct rpc_obd {
struct rpc_clnt * handle; /* RPC client handle */
struct sockaddr_in addr;
int flags; /* various flags */
int timeo;
int retrans;
int rsize; /* read size */
int wsize; /* write size */
unsigned int bsize; /* server block size */
char * hostname; /* remote hostname */
struct rpc_clnt * handle; /* RPC client handle */
struct sockaddr_in addr;
int flags; /* various flags */
int timeo;
int retrans;
int rsize; /* read size */
int wsize; /* write size */
unsigned int bsize; /* server block size */
char * hostname; /* remote hostname */
};
#define OBD_PROGRAM 300001
#define OBD_VERSION 1
#define OBDPROC_NULL 0
#define OBDPROC_ECHOINT 1
#define OBD_PROGRAM 300001
#define OBD_VERSION 1
#define OBDPROC_NULL 0
#define OBDPROC_ECHOINT 1
#ifdef OBD_NEED_XDR_TYPES
struct obd_echoint_in {
__u32 in;
__u32 in;
};
struct obd_echoint_out {
__u32 out;
__u32 out;
};
......
......@@ -22,90 +22,90 @@ extern long obd_memory;
#define CMD(cmd) (( cmd == READ ) ? "read" : "write")
/* debugging masks */
#define D_PSDEV 0x001 /* debug information from psdev.c */
#define D_PSDEV 0x001 /* debug information from psdev.c */
#define D_INODE 0x002
#define D_SUPER 0x004
#define D_SNAP 0x008
#define D_UNUSED4 0x010
#define D_WARNING 0x020 /* misc warnings */
#define D_EXT2 0x040 /* anything from ext2_debug */
#define D_MALLOC 0x080 /* print malloc, free information */
#define D_CACHE 0x100 /* cache-related items */
#define D_INFO 0x200 /* general information, especially from interface.c */
#define D_IOCTL 0x400 /* ioctl related information */
#define D_BLOCKS 0x800 /* ext2 block allocation */
#define D_RPC 0x1000 /* rpc communications */
#define D_WARNING 0x020 /* misc warnings */
#define D_EXT2 0x040 /* anything from ext2_debug */
#define D_MALLOC 0x080 /* print malloc, free information */
#define D_CACHE 0x100 /* cache-related items */
#define D_INFO 0x200 /* general information, especially from interface.c */
#define D_IOCTL 0x400 /* ioctl related information */
#define D_BLOCKS 0x800 /* ext2 block allocation */
#define D_RPC 0x1000 /* rpc communications */
#define D_PUNCH 0x2000
#define CDEBUG(mask, format, a...) \
do { \
if (obd_debug_level & mask) { \
printk("(%s:%d):", __FUNCTION__, __LINE__); \
printk(format, ## a); } \
} while (0)
do { \
if (obd_debug_level & mask) { \
printk("(%s:%d):", __FUNCTION__, __LINE__); \
printk(format, ## a); } \
} while (0)
#define ENTRY if (obd_print_entry) \
printk(KERN_INFO "Process %d entered %s\n", current->pid, __FUNCTION__)
#define ENTRY if (obd_print_entry) \
printk(KERN_INFO "Process %d entered %s\n", current->pid, __FUNCTION__)
#define EXIT if (obd_print_entry) \
printk(KERN_INFO "Process %d leaving %s [%d]\n", current->pid, \
__FUNCTION__, __LINE__)
#define EXIT if (obd_print_entry) \
printk(KERN_INFO "Process %d leaving %s [%d]\n", current->pid, \
__FUNCTION__, __LINE__)
/* Inode common information printed out (used by obdfs and ext2obd inodes) */
#define ICDEBUG(inode) { \
CDEBUG(D_INFO, \
"ino %ld, atm %ld, mtm %ld, ctm %ld, size %Ld, blocks %ld\n",\
inode->i_ino, inode->i_atime, inode->i_mtime, inode->i_ctime,\
inode->i_size, inode->i_blocks); \
CDEBUG(D_INFO, "mode %o, uid %d, gid %d, nlnk %d, count %d\n", \
inode->i_mode, inode->i_uid, inode->i_gid, inode->i_nlink,\
inode->i_count); \
#define ICDEBUG(inode) { \
CDEBUG(D_INFO, \
"ino %ld, atm %ld, mtm %ld, ctm %ld, size %Ld, blocks %ld\n",\
inode->i_ino, inode->i_atime, inode->i_mtime, inode->i_ctime,\
inode->i_size, inode->i_blocks); \
CDEBUG(D_INFO, "mode %o, uid %d, gid %d, nlnk %d, count %d\n", \
inode->i_mode, inode->i_uid, inode->i_gid, inode->i_nlink,\
atomic_read(&inode->i_count)); \
}
/* Ext2 inode information */
#define EXDEBUG(inode) { \
ICDEBUG(inode); \
CDEBUG(D_INFO, "ext2 blocks: %d %d %d %d %d %d %d %d\n", \
inode->u.ext2_i.i_data[0], inode->u.ext2_i.i_data[1], \
inode->u.ext2_i.i_data[2], inode->u.ext2_i.i_data[3], \
inode->u.ext2_i.i_data[4], inode->u.ext2_i.i_data[5], \
inode->u.ext2_i.i_data[6], inode->u.ext2_i.i_data[7]); \
#define EXDEBUG(inode) { \
ICDEBUG(inode); \
CDEBUG(D_INFO, "ext2 blocks: %d %d %d %d %d %d %d %d\n", \
inode->u.ext2_i.i_data[0], inode->u.ext2_i.i_data[1], \
inode->u.ext2_i.i_data[2], inode->u.ext2_i.i_data[3], \
inode->u.ext2_i.i_data[4], inode->u.ext2_i.i_data[5], \
inode->u.ext2_i.i_data[6], inode->u.ext2_i.i_data[7]); \
}
/* OBDFS inode information */
#define OIDEBUG(inode) { \
ICDEBUG(inode); \
CDEBUG(D_INFO,"oinfo: flags 0x%08x\n", obdfs_i2info(inode)->oi_flags);\
/* obdfs_print_plist(inode); */ \
#define OIDEBUG(inode) { \
ICDEBUG(inode); \
CDEBUG(D_INFO,"oinfo: flags 0x%08x\n", obdfs_i2info(inode)->oi_flags);\
/* obdfs_print_plist(inode); */ \
}
#define ODEBUG(obdo) { \
CDEBUG(D_INFO, "id %ld, atm %ld, mtm %ld, ctm %ld, " \
"size %ld, blocks %ld\n", \
(long)(obdo)->o_id, (long)(obdo)->o_atime, \
(long)(obdo)->o_mtime, (long)(obdo)->o_ctime, \
(long)(obdo)->o_size, (long)(obdo)->o_blocks); \
CDEBUG(D_INFO, " mode %o, uid %d, gid %d, flg 0x%0x, " \
"obdflg 0x%0x, nlnk %d, valid 0x%0x\n", \
(obdo)->o_mode, (obdo)->o_uid, (obdo)->o_gid, (obdo)->o_flags,\
(obdo)->o_obdflags, (obdo)->o_nlink, (obdo)->o_valid); \
#define ODEBUG(obdo) { \
CDEBUG(D_INFO, "id %ld, atm %ld, mtm %ld, ctm %ld, " \
"size %ld, blocks %ld\n", \
(long)(obdo)->o_id, (long)(obdo)->o_atime, \
(long)(obdo)->o_mtime, (long)(obdo)->o_ctime, \
(long)(obdo)->o_size, (long)(obdo)->o_blocks); \
CDEBUG(D_INFO, " mode %o, uid %d, gid %d, flg 0x%0x, " \
"obdflg 0x%0x, nlnk %d, valid 0x%0x\n", \
(obdo)->o_mode, (obdo)->o_uid, (obdo)->o_gid, (obdo)->o_flags,\
(obdo)->o_obdflags, (obdo)->o_nlink, (obdo)->o_valid); \
}
#define PDEBUG(page,msg) { \
if (page){ \
char *uptodate = (Page_Uptodate(page)) ? "upto" : "outof";\
char *locked = (PageLocked(page)) ? "" : "un"; \
char *buffer = page->buffers ? "buffer" : ""; \
int count = page_count(page); \
long index = page->index; \
CDEBUG(D_CACHE, "%s: ** off %ld, %sdate, %slocked, flag %ld,"\
" cnt %d page 0x%p pages %ld virt %lx %s**\n", \
msg, index, uptodate, locked, page->flags, count,\
page, page->mapping ? page->mapping->nrpages : -1,\
page->virtual, buffer); \
} else \
CDEBUG(D_CACHE, "** %s: no page\n", msg); \
#define PDEBUG(page,msg) { \
if (page){ \
char *uptodate = (Page_Uptodate(page)) ? "upto" : "outof";\
char *locked = (PageLocked(page)) ? "" : "un"; \
char *buffer = page->buffers ? "buffer" : ""; \
int count = page_count(page); \
long index = page->index; \
CDEBUG(D_CACHE, "%s: ** off %ld, %sdate, %slocked, flag %ld,"\
" cnt %d page 0x%p pages %ld virt %lx %s**\n", \
msg, index, uptodate, locked, page->flags, count,\
page, page->mapping ? page->mapping->nrpages : -1,\
page->virtual, buffer); \
} else \
CDEBUG(D_CACHE, "** %s: no page\n", msg); \
}
#if 0
......@@ -114,21 +114,21 @@ extern long obd_memory;
static inline struct inode *obd_iget(struct super_block *sb, unsigned long ino)
{
struct inode *inode;
if ((inode = iget(sb, ino)) == NULL)
CDEBUG(D_INODE, "NULL in iget for %ld\n", ino);
else
obd_inodes++;
return inode;
struct inode *inode;
if ((inode = iget(sb, ino)) == NULL)
CDEBUG(D_INODE, "NULL in iget for %ld\n", ino);
else
obd_inodes++;
return inode;
}
static inline void obd_iput(struct inode *inode)
{
if (inode == NULL)
CDEBUG(D_INODE, "NULL in iput\n");
else
obd_inodes--;
if (inode == NULL)
CDEBUG(D_INODE, "NULL in iput\n");
else
obd_inodes--;
}
#endif
......@@ -146,38 +146,38 @@ static inline void obd_iput(struct inode *inode)
#define OBD_ALLOC(ptr, cast, size) \
do { \
if (size <= 4096) { \
ptr = (cast)kmalloc((unsigned long) size, GFP_KERNEL); \
CDEBUG(D_MALLOC, "kmalloced: %d at %x.\n", \
(int) size, (int) ptr); \
} else { \
ptr = (cast)vmalloc((unsigned long) size); \
CDEBUG(D_MALLOC, "vmalloced: %d at %x.\n", \
(int) size, (int) ptr); \
} \
if (ptr == 0) { \
printk("kernel malloc returns 0 at %s:%d\n", \
__FILE__, __LINE__); \
} else { \
memset(ptr, 0, size); \
obd_memory += size; \
} \
#define OBD_ALLOC(ptr, cast, size) \
do { \
if (size <= 4096) { \
ptr = (cast)kmalloc((unsigned long) size, GFP_KERNEL); \
CDEBUG(D_MALLOC, "kmalloced: %d at %x.\n", \
(int) size, (int) ptr); \
} else { \
ptr = (cast)vmalloc((unsigned long) size); \
CDEBUG(D_MALLOC, "vmalloced: %d at %x.\n", \
(int) size, (int) ptr); \
} \
if (ptr == 0) { \
printk("kernel malloc returns 0 at %s:%d\n", \
__FILE__, __LINE__); \
} else { \
memset(ptr, 0, size); \
obd_memory += size; \
} \
} while (0)
#define OBD_FREE(ptr,size) \
do { \
if (size <= 4096) { \
kfree_s((ptr), (size)); \
CDEBUG(D_MALLOC, "kfreed: %d at %x.\n", \
(int) size, (int) ptr); \
} else { \
vfree((ptr)); \
CDEBUG(D_MALLOC, "vfreed: %d at %x.\n", \
(int) size, (int) ptr); \
} \
obd_memory -= size; \
#define OBD_FREE(ptr,size) \
do { \
if (size <= 4096) { \
kfree((ptr)); \
CDEBUG(D_MALLOC, "kfreed: %d at %x.\n", \
(int) size, (int) ptr); \
} else { \
vfree((ptr)); \
CDEBUG(D_MALLOC, "vfreed: %d at %x.\n", \
(int) size, (int) ptr); \
} \
obd_memory -= size; \
} while (0)
......
This diff is collapsed.
......@@ -6,26 +6,11 @@
*
*/
#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/string.h>
#include <linux/stat.h>
#include <linux/errno.h>
#include <linux/locks.h>
#include <linux/unistd.h>
#include <asm/system.h>
#include <asm/uaccess.h>
#include <linux/mm.h>
#include <linux/fs.h>
#include <linux/stat.h>
#include <linux/sched.h>
#include <asm/uaccess.h>
#include <linux/vmalloc.h>
#include <asm/segment.h>
#include <linux/mm.h>
#include <linux/pagemap.h>
#include <linux/smp_lock.h>
#include <linux/obd_support.h>
#include <linux/obd_class.h>
......@@ -36,106 +21,106 @@ kmem_cache_t *obdo_cachep = NULL;
int obd_init_obdo_cache(void)
{
ENTRY;
if (obdo_cachep == NULL) {
CDEBUG(D_CACHE, "allocating obdo_cache\n");
obdo_cachep = kmem_cache_create("obdo_cache",
sizeof(struct obdo),
0, SLAB_HWCACHE_ALIGN,
NULL, NULL);
if (obdo_cachep == NULL) {
EXIT;
return -ENOMEM;
} else {
CDEBUG(D_CACHE, "allocated cache at %p\n", obdo_cachep);
}
} else {
CDEBUG(D_CACHE, "using existing cache at %p\n", obdo_cachep);
}
EXIT;
return 0;
ENTRY;
if (obdo_cachep == NULL) {
CDEBUG(D_CACHE, "allocating obdo_cache\n");
obdo_cachep = kmem_cache_create("obdo_cache",
sizeof(struct obdo),
0, SLAB_HWCACHE_ALIGN,
NULL, NULL);
if (obdo_cachep == NULL) {
EXIT;
return -ENOMEM;
} else {
CDEBUG(D_CACHE, "allocated cache at %p\n", obdo_cachep);
}
} else {
CDEBUG(D_CACHE, "using existing cache at %p\n", obdo_cachep);
}
EXIT;
return 0;
}
void obd_cleanup_obdo_cache(void)
{
ENTRY;
if (obdo_cachep != NULL) {
CDEBUG(D_CACHE, "destroying obdo_cache at %p\n", obdo_cachep);
if (kmem_cache_destroy(obdo_cachep))
printk(KERN_WARNING __FUNCTION__
": unable to free cache\n");
} else
printk(KERN_INFO __FUNCTION__
": called with NULL cache pointer\n");
obdo_cachep = NULL;
EXIT;
ENTRY;
if (obdo_cachep != NULL) {
CDEBUG(D_CACHE, "destroying obdo_cache at %p\n", obdo_cachep);
if (kmem_cache_destroy(obdo_cachep))
printk(KERN_WARNING __FUNCTION__
": unable to free cache\n");
} else
printk(KERN_INFO __FUNCTION__
": called with NULL cache pointer\n");
obdo_cachep = NULL;
EXIT;
}
/* map connection to client */
struct obd_client *gen_client(struct obd_conn *conn)
{
struct obd_device * obddev = conn->oc_dev;
struct list_head * lh, * next;
struct obd_client * cli;
lh = next = &obddev->obd_gen_clients;
while ((lh = lh->next) != &obddev->obd_gen_clients) {
cli = list_entry(lh, struct obd_client, cli_chain);
if (cli->cli_id == conn->oc_id)
return cli;
}
return NULL;
struct obd_device * obddev = conn->oc_dev;
struct list_head * lh, * next;
struct obd_client * cli;
lh = next = &obddev->obd_gen_clients;
while ((lh = lh->next) != &obddev->obd_gen_clients) {
cli = list_entry(lh, struct obd_client, cli_chain);
if (cli->cli_id == conn->oc_id)
return cli;
}
return NULL;
} /* obd_client */
/* a connection defines a context in which preallocation can be managed. */
int gen_connect (struct obd_conn *conn)
{
struct obd_client * cli;
OBD_ALLOC(cli, struct obd_client *, sizeof(struct obd_client));
if ( !cli ) {
printk(__FUNCTION__ ": no memory! (minor %d)\n",
conn->oc_dev->obd_minor);
return -ENOMEM;
}
INIT_LIST_HEAD(&cli->cli_prealloc_inodes);
/* XXX this should probably spinlocked? */
cli->cli_id = ++conn->oc_dev->obd_gen_last_id;
cli->cli_prealloc_quota = 0;
cli->cli_obd = conn->oc_dev;
list_add(&(cli->cli_chain), conn->oc_dev->obd_gen_clients.prev);
CDEBUG(D_INFO, "connect: new ID %u\n", cli->cli_id);
conn->oc_id = cli->cli_id;
return 0;
struct obd_client * cli;
OBD_ALLOC(cli, struct obd_client *, sizeof(struct obd_client));
if ( !cli ) {
printk(__FUNCTION__ ": no memory! (minor %d)\n",
conn->oc_dev->obd_minor);
return -ENOMEM;
}
INIT_LIST_HEAD(&cli->cli_prealloc_inodes);
/* XXX this should probably spinlocked? */
cli->cli_id = ++conn->oc_dev->obd_gen_last_id;
cli->cli_prealloc_quota = 0;
cli->cli_obd = conn->oc_dev;
list_add(&(cli->cli_chain), conn->oc_dev->obd_gen_clients.prev);
CDEBUG(D_INFO, "connect: new ID %u\n", cli->cli_id);
conn->oc_id = cli->cli_id;
return 0;
} /* gen_obd_connect */
int gen_disconnect(struct obd_conn *conn)
{
struct obd_client * cli;
ENTRY;
struct obd_client * cli;
ENTRY;
if (!(cli = gen_client(conn))) {
CDEBUG(D_IOCTL, "disconnect: attempting to free "
"nonexistent client %u\n", conn->oc_id);
return -EINVAL;
}
if (!(cli = gen_client(conn))) {
CDEBUG(D_IOCTL, "disconnect: attempting to free "
"nonexistent client %u\n", conn->oc_id);
return -EINVAL;
}
list_del(&(cli->cli_chain));
OBD_FREE(cli, sizeof(struct obd_client));
list_del(&(cli->cli_chain));
OBD_FREE(cli, sizeof(struct obd_client));
CDEBUG(D_INFO, "disconnect: ID %u\n", conn->oc_id);
CDEBUG(D_INFO, "disconnect: ID %u\n", conn->oc_id);
EXIT;
return 0;
EXIT;
return 0;
} /* gen_obd_disconnect */
......@@ -146,43 +131,43 @@ int gen_disconnect(struct obd_conn *conn)
*/
int gen_multi_setup(struct obd_device *obddev, uint32_t len, void *data)
{
int i;
for (i = 0 ; i < obddev->obd_multi_count ; i++ ) {
int rc;
struct obd_conn *ch_conn = &obddev->obd_multi_conn[i];
rc = OBP(ch_conn->oc_dev, connect)(ch_conn);
if ( rc != 0 ) {
int j;
for (j = --i; j >= 0; --j) {
ch_conn = &obddev->obd_multi_conn[i];
OBP(ch_conn->oc_dev, disconnect)(ch_conn);
}
return -EINVAL;
}
}
return 0;
int i;
for (i = 0 ; i < obddev->obd_multi_count ; i++ ) {
int rc;
struct obd_conn *ch_conn = &obddev->obd_multi_conn[i];
rc = OBP(ch_conn->oc_dev, connect)(ch_conn);
if ( rc != 0 ) {
int j;
for (j = --i; j >= 0; --j) {
ch_conn = &obddev->obd_multi_conn[i];
OBP(ch_conn->oc_dev, disconnect)(ch_conn);
}
return -EINVAL;
}
}
return 0;
}
#if 0
int gen_multi_attach(struct obd_device *obddev, int len, void *data)
{
int i;
int count;
struct obd_device *rdev = obddev->obd_multi_dev[0];
count = len/sizeof(int);
obddev->obd_multi_count = count;
for (i=0 ; i<count ; i++) {
rdev = &obd_dev[*((int *)data + i)];
rdev = rdev + 1;
CDEBUG(D_INFO, "OBD RAID1: replicator %d is of type %s\n", i,
(rdev + i)->obd_type->typ_name);
}
return 0;
int i;
int count;
struct obd_device *rdev = obddev->obd_multi_dev[0];
count = len/sizeof(int);
obddev->obd_multi_count = count;
for (i=0 ; i<count ; i++) {
rdev = &obd_dev[*((int *)data + i)];
rdev = rdev + 1;
CDEBUG(D_INFO, "OBD RAID1: replicator %d is of type %s\n", i,
(rdev + i)->obd_type->typ_name);
}
return 0;
}
#endif
......@@ -194,20 +179,20 @@ int gen_multi_attach(struct obd_device *obddev, int len, void *data)
*/
int gen_multi_cleanup(struct obd_device *obddev)
{
int i;
for (i = 0 ; i < obddev->obd_multi_count ; i++ ) {
struct obd_conn *ch_conn = &obddev->obd_multi_conn[i];
int rc;
rc = OBP(ch_conn->oc_dev, disconnect)(ch_conn);
if ( rc != 0 ) {
printk(KERN_WARNING __FUNCTION__
": disconnect failure %d\n",
ch_conn->oc_dev->obd_minor);
}
}
return 0;
int i;
for (i = 0 ; i < obddev->obd_multi_count ; i++ ) {
struct obd_conn *ch_conn = &obddev->obd_multi_conn[i];
int rc;
rc = OBP(ch_conn->oc_dev, disconnect)(ch_conn);
if ( rc != 0 ) {
printk(KERN_WARNING __FUNCTION__
": disconnect failure %d\n",
ch_conn->oc_dev->obd_minor);
}
}
return 0;
} /* gen_multi_cleanup_device */
......@@ -218,18 +203,18 @@ int gen_multi_cleanup(struct obd_device *obddev)
*/
int gen_cleanup(struct obd_device * obddev)
{
struct list_head * lh, * tmp;
struct obd_client * cli;
ENTRY;
lh = tmp = &obddev->obd_gen_clients;
while ((tmp = tmp->next) != lh) {
cli = list_entry(tmp, struct obd_client, cli_chain);
CDEBUG(D_INFO, "Disconnecting obd_connection %d, at %p\n",
cli->cli_id, cli);
}
return 0;
struct list_head * lh, * tmp;
struct obd_client * cli;
ENTRY;
lh = tmp = &obddev->obd_gen_clients;
while ((tmp = tmp->next) != lh) {
cli = list_entry(tmp, struct obd_client, cli_chain);
CDEBUG(D_INFO, "Disconnecting obd_connection %d, at %p\n",
cli->cli_id, cli);
}
return 0;
} /* sim_cleanup_device */
void ___wait_on_page(struct page *page)
......@@ -256,69 +241,69 @@ void lck_page(struct page *page)
}
int gen_copy_data(struct obd_conn *dst_conn, struct obdo *dst,
struct obd_conn *src_conn, struct obdo *src,
obd_size count, obd_off offset)
struct obd_conn *src_conn, struct obdo *src,
obd_size count, obd_off offset)
{
struct page *page;
unsigned long index = 0;
int err = 0;
ENTRY;
CDEBUG(D_INFO, "src: ino %Ld blocks %Ld, size %Ld, dst: ino %Ld\n",
src->o_id, src->o_blocks, src->o_size, dst->o_id);
page = alloc_page(GFP_USER);
if ( !page ) {
EXIT;
return -ENOMEM;
}
lck_page(page);
/* XXX with brw vector I/O, we could batch up reads and writes here,
* all we need to do is allocate multiple pages to handle the I/Os
* and arrays to handle the request parameters.
*/
while (index < ((src->o_size + PAGE_SIZE - 1) >> PAGE_SHIFT)) {
obd_count num_oa = 1;
obd_count num_buf = 1;
char *buf;
obd_size brw_count = PAGE_SIZE;
obd_off brw_offset = (page->index) << PAGE_SHIFT;
obd_flag flagr = 0;
obd_flag flagw = OBD_BRW_CREATE;
page->index = index;
buf = (char *)page_address(page);
err = OBP(src_conn->oc_dev, brw)(READ, src_conn, num_oa, &src,
&num_buf, &buf, &brw_count,
&brw_offset, &flagr);
if ( err ) {
EXIT;
break;
}
CDEBUG(D_INFO, "Read page %ld ...\n", page->index);
err = OBP(dst_conn->oc_dev, brw)(WRITE, dst_conn, num_oa, &dst,
&num_buf, &buf, &brw_count,
&brw_offset, &flagw);
/* XXX should handle dst->o_size, dst->o_blocks here */
if ( err ) {
EXIT;
break;
}
CDEBUG(D_INFO, "Wrote page %ld ...\n", page->index);
index++;
}
dst->o_size = src->o_size;
dst->o_blocks = src->o_blocks;
dst->o_valid |= (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS);
UnlockPage(page);
__free_page(page);
EXIT;
return err;
struct page *page;
unsigned long index = 0;
int err = 0;
ENTRY;
CDEBUG(D_INFO, "src: ino %Ld blocks %Ld, size %Ld, dst: ino %Ld\n",
src->o_id, src->o_blocks, src->o_size, dst->o_id);
page = alloc_page(GFP_USER);
if ( !page ) {
EXIT;
return -ENOMEM;
}
lck_page(page);
/* XXX with brw vector I/O, we could batch up reads and writes here,
* all we need to do is allocate multiple pages to handle the I/Os
* and arrays to handle the request parameters.
*/
while (index < ((src->o_size + PAGE_SIZE - 1) >> PAGE_SHIFT)) {
obd_count num_oa = 1;
obd_count num_buf = 1;
char *buf;
obd_size brw_count = PAGE_SIZE;
obd_off brw_offset = (page->index) << PAGE_SHIFT;
obd_flag flagr = 0;
obd_flag flagw = OBD_BRW_CREATE;
page->index = index;
buf = (char *)page_address(page);
err = OBP(src_conn->oc_dev, brw)(READ, src_conn, num_oa, &src,
&num_buf, &buf, &brw_count,
&brw_offset, &flagr);
if ( err ) {
EXIT;
break;
}
CDEBUG(D_INFO, "Read page %ld ...\n", page->index);
err = OBP(dst_conn->oc_dev, brw)(WRITE, dst_conn, num_oa, &dst,
&num_buf, &buf, &brw_count,
&brw_offset, &flagw);
/* XXX should handle dst->o_size, dst->o_blocks here */
if ( err ) {
EXIT;
break;
}
CDEBUG(D_INFO, "Wrote page %ld ...\n", page->index);
index++;
}
dst->o_size = src->o_size;
dst->o_blocks = src->o_blocks;
dst->o_valid |= (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS);
UnlockPage(page);
__free_page(page);
EXIT;
return err;
}
#include <linux/autoconf.h>
#include <linux/sysctl.h>
#include <linux/sched.h>
#include <linux/mm.h>
#include <linux/sysctl.h>
......@@ -19,16 +21,16 @@ static int vars[2];
static int index = 0;
static int obd_sctl_vars( ctl_table * table, int write, struct file *
filp, void * buffer, size_t * lenp );
filp, void * buffer, size_t * lenp );
static int obd_sctl_reset( ctl_table * table, int write, struct file
* filp, void * buffer, size_t * lenp );
* filp, void * buffer, size_t * lenp );
#define OBD_SYSCTL 1
#define OBD_SYSCTL 300
#define OBD_DEBUG 1 /* control debugging */
#define OBD_ENTRY 2 /* control enter/leave pattern */
#define OBD_DEBUG 1 /* control debugging */
#define OBD_ENTRY 2 /* control enter/leave pattern */
#define OBD_TIMEOUT 3 /* timeout on upcalls to become intrble */
#define OBD_HARD 4 /* mount type "hard" or "soft" */
#define OBD_VARS 5
......@@ -38,69 +40,67 @@ static int obd_sctl_reset( ctl_table * table, int write, struct file
#define OBD_VARS_SLOT 2
static ctl_table obd_table[] = {
{OBD_DEBUG, "debug", &obd_debug_level, sizeof(int), 0644, NULL, &proc_dointvec},
{OBD_ENTRY, "trace", &obd_print_entry, sizeof(int), 0644, NULL, &proc_dointvec},
{OBD_VARS, "vars", &vars[0], sizeof(int), 0644, NULL, &proc_dointvec},
{OBD_INDEX, "index", &index, sizeof(int), 0644, NULL, &obd_sctl_vars},
{OBD_RESET, "reset", NULL, 0, 0644, NULL, &obd_sctl_reset},
{ 0 }
{OBD_DEBUG, "debug", &obd_debug_level, sizeof(int), 0644, NULL, &proc_dointvec},
{OBD_ENTRY, "trace", &obd_print_entry, sizeof(int), 0644, NULL, &proc_dointvec},
{OBD_VARS, "vars", &vars[0], sizeof(int), 0644, NULL, &proc_dointvec},
{OBD_INDEX, "index", &index, sizeof(int), 0644, NULL, &obd_sctl_vars},
{OBD_RESET, "reset", NULL, 0, 0644, NULL, &obd_sctl_reset},
{ 0 }
};
#if 0
static ctl_table jukebox_table[] = {
static ctl_table parent_table[] = {
{OBD_SYSCTL, "obd", NULL, 0, 0555, obd_table},
{0}
};
#endif
void obd_sysctl_init (void)
{
#ifdef CONFIG_SYSCTL
if ( !obd_table_header )
obd_table_header = register_sysctl_table(jukebox_table, 0);
if ( !obd_table_header )
obd_table_header = register_sysctl_table(parent_table, 0);
#endif
}
void obd_sysctl_clean (void)
{
#ifdef CONFIG_SYSCTL
if ( obd_table_header )
unregister_sysctl_table(obd_table_header);
obd_table_header = NULL;
if ( obd_table_header )
unregister_sysctl_table(obd_table_header);
obd_table_header = NULL;
#endif
}
int obd_sctl_reset (ctl_table * table, int write,
struct file * filp, void * buffer,
size_t * lenp)
struct file * filp, void * buffer,
size_t * lenp)
{
if ( write ) {
/* do something here */
vars[0]=0;
vars[1]=0;
}
*lenp = 0;
return 0;
if ( write ) {
/* do something here */
vars[0]=0;
vars[1]=0;
}
*lenp = 0;
return 0;
}
int obd_sctl_vars (ctl_table * table, int write,
struct file * filp, void * buffer,
size_t * lenp)
struct file * filp, void * buffer,
size_t * lenp)
{
int rc;
int rc;
rc = proc_dointvec(table, write, filp, buffer, lenp);
rc = proc_dointvec(table, write, filp, buffer, lenp);
if ( rc )
return rc;
if ( rc )
return rc;
if ( index < 0 || index > 1 ) {
printk(KERN_WARNING __FUNCTION__ "Illegal index %d!\n", index);
index = 0;
} else {
obd_table[OBD_VARS_SLOT].data = &vars[index];
}
if ( index < 0 || index > 1 ) {
printk(KERN_WARNING __FUNCTION__ "Illegal index %d!\n", index);
index = 0;
} else {
obd_table[OBD_VARS_SLOT].data = &vars[index];
}
return rc;
return rc;
}
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment