From e8fc23a5e634768ed079d9e7e22c0805d4afd392 Mon Sep 17 00:00:00 2001 From: wangdi Date: Tue, 6 Jul 2004 11:25:15 +0000 Subject: [PATCH] Update snap 1)some fix for snap 2)add snap_add command --- lustre/include/linux/lustre_fsfilt.h | 21 ++++-- lustre/include/linux/lustre_smfs.h | 4 +- lustre/include/linux/lustre_snap.h | 6 +- lustre/lvfs/fsfilt_smfs.c | 15 ++++ lustre/lvfs/fsfilt_snap_ext3.c | 14 +++- lustre/lvfs/fsfilt_snap_smfs.c | 23 +++--- lustre/mds/mds_lov.c | 8 +- lustre/smfs/inode.c | 6 +- lustre/smfs/smfs_cow.c | 141 +++++++++++++++++++++++++++++------ lustre/smfs/smfs_internal.h | 6 +- lustre/smfs/super.c | 6 +- lustre/tests/lsnap.sh | 5 ++ lustre/utils/lctl.c | 2 + lustre/utils/obd.c | 19 +++++ 14 files changed, 224 insertions(+), 52 deletions(-) create mode 100755 lustre/tests/lsnap.sh diff --git a/lustre/include/linux/lustre_fsfilt.h b/lustre/include/linux/lustre_fsfilt.h index 204004e..67e9211 100644 --- a/lustre/include/linux/lustre_fsfilt.h +++ b/lustre/include/linux/lustre_fsfilt.h @@ -58,8 +58,8 @@ struct fsfilt_operations { int (* fs_iocontrol)(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg); int (* fs_set_md)(struct inode *inode, void *handle, void *md, - int size, int flags); - int (* fs_get_md)(struct inode *inode, void *md, int size, int flags); + int size); + int (* fs_get_md)(struct inode *inode, void *md, int size); /* this method is needed to make IO operation fsfilt nature depend. */ #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) @@ -152,6 +152,7 @@ struct fsfilt_operations { int (* fs_get_snap_info)(struct super_block *sb, struct inode *inode, void* key, __u32 keylen, void *val, __u32 *vallen); + int (* fs_set_snap_item)(struct super_block *sb, char *name); }; extern int fsfilt_register_ops(struct fsfilt_operations *fs_ops); @@ -367,16 +368,16 @@ static inline int fsfilt_setup(struct obd_device *obd, } static inline int fsfilt_set_md(struct obd_device *obd, struct inode *inode, - void *handle, void *md, int size, int flags) + void *handle, void *md, int size) { - return obd->obd_fsops->fs_set_md(inode, handle, md, size, flags); + return obd->obd_fsops->fs_set_md(inode, handle, md, size); } static inline int fsfilt_get_md(struct obd_device *obd, struct inode *inode, - void *md, int size, int flags) + void *md, int size) { - return obd->obd_fsops->fs_get_md(inode, md, size, flags); + return obd->obd_fsops->fs_get_md(inode, md, size); } #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) @@ -649,6 +650,14 @@ fsfilt_del_dir_entry(struct obd_device *obd, struct dentry *dentry) return obd->obd_fsops->fs_del_dir_entry(obd, dentry); } +static inline int +fsfilt_set_snap_item(struct obd_device *obd, struct super_block *sb, + char *name) +{ + if (obd->obd_fsops->fs_set_snap_item) + return obd->obd_fsops->fs_set_snap_item(sb, name); + return 0; +} #endif /* __KERNEL__ */ #endif diff --git a/lustre/include/linux/lustre_smfs.h b/lustre/include/linux/lustre_smfs.h index 738eb6f..68cf9e2 100644 --- a/lustre/include/linux/lustre_smfs.h +++ b/lustre/include/linux/lustre_smfs.h @@ -137,7 +137,9 @@ struct fs_extent{ (inode->i_sb->s_fs_info))->sm_cache_fsfilt) #endif -#define I2SNAPOPS(inode) ((S2SMI(inode->i_sb))->smsi_snap_info->snap_cache_fsfilt) +#define I2SNAPI(inode) (&(I2SMI(inode)->sm_sninfo)) +#define I2SNAPCOPS(inode) ((S2SMI(inode->i_sb))->smsi_snap_info->snap_cache_fsfilt) +#define I2SNAPOPS(inode) ((S2SMI(inode->i_sb))->smsi_snap_info->snap_fsfilt) #define S2SNAPI(sb) (S2SMI(sb)->smsi_snap_info) #define F2SMFI(file) ((struct smfs_file_info *)((file->private_data))) diff --git a/lustre/include/linux/lustre_snap.h b/lustre/include/linux/lustre_snap.h index 3962a52..d93880d 100644 --- a/lustre/include/linux/lustre_snap.h +++ b/lustre/include/linux/lustre_snap.h @@ -142,7 +142,7 @@ struct snap_ea{ #define SNAP_MAX_NAMELEN 64 #define MAX_SNAPTABLE_COUNT "MAXSnapCount" -#define SNAP_TABLE_MAGIC 0x19760218 +#define SNAPTABLE_MAGIC 0x19760218 #define SNAPTABLE_INFO "snaptable" #define SNAP_GENERATION "snap_generation" struct snap { @@ -150,7 +150,7 @@ struct snap { unsigned int sn_index; unsigned int sn_gen; unsigned int sn_flags; - char name[SNAP_MAX_NAMELEN]; + char sn_name[SNAP_MAX_NAMELEN]; }; struct snap_table { @@ -168,5 +168,5 @@ struct snap_info { spinlock_t sntbl_lock; struct snap_table *sntbl; }; - +extern int smfs_add_snap_item(struct super_block *sb, char *name); #endif /*_LUSTRE_SNAP_H*/ diff --git a/lustre/lvfs/fsfilt_smfs.c b/lustre/lvfs/fsfilt_smfs.c index f0059f3..f3f4675 100644 --- a/lustre/lvfs/fsfilt_smfs.c +++ b/lustre/lvfs/fsfilt_smfs.c @@ -39,6 +39,8 @@ #include #include +#include +#include static void *fsfilt_smfs_start(struct inode *inode, int op, void *desc_private, int logs) { @@ -899,6 +901,17 @@ out: return rc; } +static int fsfilt_smfs_set_snap_item(struct super_block *sb, char *name) +{ + int rc = 0; + + ENTRY; +#if CONFIG_SNAPFS + rc = smfs_add_snap_item(sb, name); +#endif + RETURN(rc); +} + static struct fsfilt_operations fsfilt_smfs_ops = { .fs_type = "smfs", .fs_owner = THIS_MODULE, @@ -938,6 +951,8 @@ static struct fsfilt_operations fsfilt_smfs_ops = { .fs_get_ino_write_extents = fsfilt_smfs_get_ino_write_extents, .fs_free_write_extents = fsfilt_smfs_free_extents, .fs_write_extents = fsfilt_smfs_write_extents, + .fs_set_snap_item = fsfilt_smfs_set_snap_item, + /* FIXME-UMKA: probably fsfilt_smfs_get_op_len() should be * put here too. */ }; diff --git a/lustre/lvfs/fsfilt_snap_ext3.c b/lustre/lvfs/fsfilt_snap_ext3.c index b183bf6..4d050b6 100644 --- a/lustre/lvfs/fsfilt_snap_ext3.c +++ b/lustre/lvfs/fsfilt_snap_ext3.c @@ -1464,6 +1464,11 @@ static int fsfilt_ext3_get_snap_info(struct super_block *sb,struct inode *inode, rc = ext3_xattr_get(inode, EXT3_SNAP_INDEX,EXT3_SNAP_GENERATION, (char *)val, *vallen); + if (rc == -ENOATTR) { + *((__u32 *)val) = 0; + *vallen = sizeof(int); + rc = 0; + } RETURN(rc); } RETURN(-EINVAL); @@ -1483,19 +1488,20 @@ static int fsfilt_ext3_set_snap_info(struct super_block *sb,struct inode *inode, if (keylen >= strlen(SNAPTABLE_INFO) && strcmp(key, SNAPTABLE_INFO) == 0) { - struct inode *inode = sb->s_root->d_inode; + struct inode *root_inode = sb->s_root->d_inode; handle_t *handle; - handle = ext3_journal_start(inode, EXT3_XATTR_TRANS_BLOCKS); + handle = ext3_journal_start(root_inode, EXT3_XATTR_TRANS_BLOCKS); if( !handle ) RETURN(-EINVAL); - rc = ext3_xattr_set(handle, inode, EXT3_SNAP_INDEX, + rc = ext3_xattr_set(handle, root_inode, EXT3_SNAP_INDEX, EXT3_SNAPTABLE_EA, val, *vallen, 0); - ext3_journal_stop(handle,inode); + ext3_journal_stop(handle,root_inode); RETURN(rc); } else if (keylen >= strlen(SNAP_GENERATION) && strcmp(key, SNAP_GENERATION) == 0) { + LASSERT(inode); rc = ext3_set_generation(inode, *(int*)val); RETURN(rc); diff --git a/lustre/lvfs/fsfilt_snap_smfs.c b/lustre/lvfs/fsfilt_snap_smfs.c index bd300f4..764811d 100644 --- a/lustre/lvfs/fsfilt_snap_smfs.c +++ b/lustre/lvfs/fsfilt_snap_smfs.c @@ -46,7 +46,7 @@ static struct inode* fsfilt_smfs_create_indirect(struct inode *inode, struct inode *parent, int del) { - struct fsfilt_operations *snap_fsfilt = I2SNAPOPS(inode); + struct fsfilt_operations *snap_fsfilt = I2SNAPCOPS(inode); struct inode *cache_inode = NULL; struct inode *cache_parent = NULL; struct inode *cache_ind_inode = NULL; @@ -83,7 +83,7 @@ static struct inode* fsfilt_smfs_create_indirect(struct inode *inode, static struct inode* fsfilt_smfs_get_indirect(struct inode *inode, int *table, int slot) { - struct fsfilt_operations *snap_fsfilt = I2SNAPOPS(inode); + struct fsfilt_operations *snap_fsfilt = I2SNAPCOPS(inode); struct inode *cache_inode = NULL; struct inode *cache_ind_inode = NULL; struct inode *ind_inode = NULL; @@ -113,7 +113,7 @@ static struct inode* fsfilt_smfs_get_indirect(struct inode *inode, static int fsfilt_smfs_set_indirect(struct inode *inode, int index, ino_t ind_ino, ino_t parent_ino) { - struct fsfilt_operations *snap_fsfilt = I2SNAPOPS(inode); + struct fsfilt_operations *snap_fsfilt = I2SNAPCOPS(inode); struct inode *cache_inode = NULL; int rc = -EIO; ENTRY; @@ -154,7 +154,7 @@ static int fsfilt_smfs_snap_feature(struct super_block *sb, int feature, static int fsfilt_smfs_is_redirector(struct inode *inode) { - struct fsfilt_operations *snap_fsfilt = I2SNAPOPS(inode); + struct fsfilt_operations *snap_fsfilt = I2SNAPCOPS(inode); struct inode *cache_inode = NULL; int rc = -EIO; ENTRY; @@ -175,7 +175,7 @@ static int fsfilt_smfs_is_redirector(struct inode *inode) } static int fsfilt_smfs_is_indirect(struct inode *inode) { - struct fsfilt_operations *snap_fsfilt = I2SNAPOPS(inode); + struct fsfilt_operations *snap_fsfilt = I2SNAPCOPS(inode); struct inode *cache_inode = NULL; int rc = -EIO; ENTRY; @@ -196,7 +196,7 @@ static int fsfilt_smfs_is_indirect(struct inode *inode) } static ino_t fsfilt_smfs_get_indirect_ino(struct inode *inode, int index) { - struct fsfilt_operations *snap_fsfilt = I2SNAPOPS(inode); + struct fsfilt_operations *snap_fsfilt = I2SNAPCOPS(inode); struct inode *cache_inode = NULL; int rc = -EIO; ENTRY; @@ -219,7 +219,7 @@ static ino_t fsfilt_smfs_get_indirect_ino(struct inode *inode, int index) static int fsfilt_smfs_destroy_indirect(struct inode *inode, int index, struct inode *next_ind) { - struct fsfilt_operations *snap_fsfilt = I2SNAPOPS(inode); + struct fsfilt_operations *snap_fsfilt = I2SNAPCOPS(inode); struct inode *cache_inode = NULL; struct inode *cache_next = NULL; int rc = -EIO; @@ -249,7 +249,7 @@ static int fsfilt_smfs_destroy_indirect(struct inode *inode, int index, } static int fsfilt_smfs_restore_indirect(struct inode *inode, int index) { - struct fsfilt_operations *snap_fsfilt = I2SNAPOPS(inode); + struct fsfilt_operations *snap_fsfilt = I2SNAPCOPS(inode); struct inode *cache_inode = NULL; int rc = -EIO; ENTRY; @@ -293,7 +293,7 @@ static int fsfilt_smfs_iterate(struct super_block *sb, static int fsfilt_smfs_copy_block(struct inode *dst, struct inode *src, int blk) { - struct fsfilt_operations *snap_fsfilt = I2SNAPOPS(dst); + struct fsfilt_operations *snap_fsfilt = I2SNAPCOPS(dst); struct inode *cache_dst = NULL; struct inode *cache_src = NULL; int rc = -EIO; @@ -336,7 +336,7 @@ static int fsfilt_smfs_set_snap_info(struct super_block *sb,struct inode *inode, snap_fsfilt = S2SNAPI(sb)->snap_cache_fsfilt; } else if (inode) { cache_inode = I2CI(inode); - snap_fsfilt = I2SNAPOPS(inode); + snap_fsfilt = I2SNAPCOPS(inode); } if (snap_fsfilt == NULL) @@ -363,7 +363,7 @@ static int fsfilt_smfs_get_snap_info(struct super_block *sb, struct inode *inode snap_fsfilt = S2SNAPI(sb)->snap_cache_fsfilt; } else if (inode) { cache_inode = I2CI(inode); - snap_fsfilt = I2SNAPOPS(inode); + snap_fsfilt = I2SNAPCOPS(inode); } if (snap_fsfilt == NULL) @@ -375,7 +375,6 @@ static int fsfilt_smfs_get_snap_info(struct super_block *sb, struct inode *inode RETURN(rc); } - struct fsfilt_operations fsfilt_smfs_snap_ops = { .fs_type = "smfs_snap", .fs_owner = THIS_MODULE, diff --git a/lustre/mds/mds_lov.c b/lustre/mds/mds_lov.c index 73a4629..5efd5f4 100644 --- a/lustre/mds/mds_lov.c +++ b/lustre/mds/mds_lov.c @@ -426,7 +426,13 @@ int mds_iocontrol(unsigned int cmd, struct obd_export *exp, int len, OBD_FREE(cfg_buf, data->ioc_plen1); RETURN(rc); } - + case OBD_IOC_SNAP_ADD: { + char *name = data->ioc_inlbuf1; + if (name) { + rc = fsfilt_set_snap_item(obd, mds->mds_sb, name); + } + RETURN(rc); + } case OBD_IOC_PARSE: { struct llog_ctxt *ctxt = llog_get_context(&obd->obd_llogs, LLOG_CONFIG_ORIG_CTXT); diff --git a/lustre/smfs/inode.c b/lustre/smfs/inode.c index f183888..f01f1d0 100644 --- a/lustre/smfs/inode.c +++ b/lustre/smfs/inode.c @@ -78,7 +78,11 @@ static void smfs_read_inode2(struct inode *inode, void *opaque) post_smfs_inode(inode, cache_inode); sm_set_inode_ops(cache_inode, inode); - +#if CONFIG_SNAPFS + if (SMFS_DO_COW(S2SMI(inode->i_sb))) { + smfs_init_snap_inode_info(inode, *((int *)opaque)); + } +#endif CDEBUG(D_INODE, "read_inode ino %lu icount %d \n", inode->i_ino, atomic_read(&inode->i_count)); return; diff --git a/lustre/smfs/smfs_cow.c b/lustre/smfs/smfs_cow.c index 5b611fb..2b5c75c 100644 --- a/lustre/smfs/smfs_cow.c +++ b/lustre/smfs/smfs_cow.c @@ -43,9 +43,10 @@ static int smfs_init_snaptabe(struct super_block *sb) { struct snap_info *snap_info = S2SNAPI(sb); - struct fsfilt_operations *snapops; + struct snap_table *snap_table = NULL; + struct fsfilt_operations *snapops = snap_info->snap_fsfilt; int rc = 0, size, table_size, vallen; - + ENTRY; init_MUTEX(&snap_info->sntbl_sema); @@ -68,30 +69,32 @@ static int smfs_init_snaptabe(struct super_block *sb) CERROR("No MEM\n"); RETURN(-ENOMEM); } + snap_table = snap_info->sntbl; + + snap_table->sntbl_magic = cpu_to_le32((__u32)SNAPTABLE_MAGIC); + snap_table->sntbl_max_count = size; /*get snaptable info*/ + rc = snapops->fs_get_snap_info(sb, NULL, SNAPTABLE_INFO, strlen(SNAPTABLE_INFO), - snap_info->sntbl, &table_size); - + snap_table, &table_size); if (rc < 0) { if (rc == -ENOATTR) { - snap_info->sntbl->sntbl_count = 1; + snap_table->sntbl_count = 0; CDEBUG(D_INFO, "No snaptable here\n"); RETURN(0); } else { CERROR("Can not retrive the snaptable from this filesystem\n"); - OBD_FREE(snap_info->sntbl, table_size); + OBD_FREE(snap_table, table_size); RETURN(rc); } } - if (le32_to_cpu(snap_info->sntbl->sntbl_magic) != SNAP_TABLE_MAGIC) { + if (le32_to_cpu(snap_table->sntbl_magic) != SNAPTABLE_MAGIC) { CERROR("On disk snaptable is not right \n"); - OBD_FREE(snap_info->sntbl, table_size); + OBD_FREE(snap_table, table_size); RETURN(-EIO); } - snap_info->sntbl->sntbl_max_count = size; - - return 0; + RETURN(rc); } int smfs_cow_init(struct super_block *sb) @@ -146,15 +149,19 @@ int smfs_cow_cleanup(struct super_block *sb) { struct smfs_super_info *smfs_info = S2SMI(sb); struct snap_info *snap_info = S2SNAPI(sb); - struct inode *inode = sb->s_root->d_inode; - int rc = 0; + struct snap_table *snap_table = snap_info->sntbl; + int rc = 0, table_size; ENTRY; SMFS_CLEAN_COW(smfs_info); - SMFS_CLEAN_INODE_COW(inode); + + if (snap_info->snap_fsfilt) + fsfilt_put_ops(snap_info->snap_fsfilt); + if (snap_info->snap_cache_fsfilt) + fsfilt_put_ops(snap_info->snap_cache_fsfilt); - if (snap_info->sntbl) { - int table_size = SNAPTABLE_SIZE(snap_info->sntbl->sntbl_max_count); + if (snap_table) { + table_size = SNAPTABLE_SIZE(snap_table->sntbl_max_count); OBD_FREE(snap_info->sntbl, table_size); } if (snap_info) @@ -163,6 +170,25 @@ int smfs_cow_cleanup(struct super_block *sb) RETURN(rc); } +/*FIXME Note indirect and primary inode +* should be recorgnized here*/ +int smfs_init_snap_inode_info(struct inode *inode, int flags) +{ + struct snap_inode_info *sni_info = I2SNAPI(inode); + struct fsfilt_operations *snapops = I2SNAPOPS(inode); + int vallen, rc = 0; + ENTRY; + + sni_info->sn_flags = flags; + vallen = sizeof(sni_info->sn_gen); + + rc = snapops->fs_get_snap_info(NULL, inode, SNAP_GENERATION, + strlen(SNAP_GENERATION), + &sni_info->sn_gen, &vallen); + + RETURN(rc); + +} /* latest snap: returns - the index of the latest snapshot before NOW - hence it returns 0 in case all the volume snapshots lie in the future @@ -177,17 +203,90 @@ void snap_last(struct super_block *sb, struct snap *snap) ENTRY; /* start at the highest index in the superblock snaptime array */ - i = table->sntbl_count - 1; - - snap->sn_index = table->sntbl_items[i].sn_index; - snap->sn_time = table->sntbl_items[i].sn_time; - snap->sn_gen = table->sntbl_items[i].sn_gen; + if (table->sntbl_count == 0) { + memset(snap, 0, sizeof(struct snap)); + } else { + i = table->sntbl_count - 1; + snap->sn_index = table->sntbl_items[i].sn_index; + snap->sn_time = table->sntbl_items[i].sn_time; + snap->sn_gen = table->sntbl_items[i].sn_gen; + } CDEBUG(D_INFO, "index: %d, time[i]: %ld, now: %ld\n", snap->sn_index, snap->sn_time, now); EXIT; return; } +static int inline get_index_of_item(struct snap_table *table, char *name) +{ + int count = table->sntbl_count; + int i, j; + ENTRY; + + for (i = 0; i < table->sntbl_max_count; i++) { + if (!strcmp(name, table->sntbl_items[i].sn_name)) { + CERROR("Duplicate name %s in snaptable\n", name); + RETURN(-EINVAL); + } + } + + for (i = 0; i < table->sntbl_max_count; i++) { + int found = 0; + for (j = 0; j < (count + 1); j++) { + if (table->sntbl_items[j].sn_index == i) { + found = 1; + break; + } + } + if (!found) + RETURN(i); + } + CERROR("snaptable Full\n"); + RETURN(-ENOSPC); +} + +int smfs_add_snap_item(struct super_block *sb, char *name) +{ + struct snap_info *snap_info = S2SNAPI(sb); + struct fsfilt_operations *snapops = snap_info->snap_fsfilt; + struct snap_table *snap_table = snap_info->sntbl; + struct snap *snap_item; + int table_size, count = 0, index = 0, rc = 0; + + count = snap_table->sntbl_count + 1; + /* XXX Is down this sema necessary*/ + down_interruptible(&snap_info->sntbl_sema); + snap_item = &snap_table->sntbl_items[count]; + + /*add item in snap_table set generation*/ + snap_item->sn_time = CURRENT_TIME; + /* find table index */ + index = get_index_of_item(snap_table, name); + if (index < 0) + GOTO(exit, rc = index); + + snap_item->sn_index = index; + snap_item->sn_flags = 0; + snap_item->sn_gen = snap_table->sntbl_generation + 1; + memcpy(snap_item->sn_name, name, SNAP_MAX_NAMELEN); + /* Wrote the whole snap_table to disk */ + table_size = SNAPTABLE_SIZE(snap_table->sntbl_max_count); + + rc = snapops->fs_set_snap_info(sb, NULL, SNAPTABLE_INFO, + strlen(SNAPTABLE_INFO), + snap_table, &table_size); + if (rc) { + CERROR("Set snaptable error rc=%d\n", rc); + GOTO(exit, rc); + } + snap_table->sntbl_count++; + snap_table->sntbl_generation++; +exit: + up(&snap_info->sntbl_sema); + RETURN(rc); + +} +EXPORT_SYMBOL(smfs_add_snap_item); /* * Note: this function should be differnet with snap_do_cow. * In smfs_do_cow, we check the EA for whether do cow for that inode. diff --git a/lustre/smfs/smfs_internal.h b/lustre/smfs/smfs_internal.h index 541afbf4..46a750f 100644 --- a/lustre/smfs/smfs_internal.h +++ b/lustre/smfs/smfs_internal.h @@ -198,7 +198,6 @@ extern int init_smfs_psdev(void); extern void smfs_cleanup_psdev(void); /*smfs_cow.c */ -extern int smfs_cow_init(struct super_block *sb); /* cache_space.c */ extern int do_cache_manage; struct cache_purge_queue { @@ -308,7 +307,7 @@ static inline int get_active_entry(struct inode *dir, __u64 *active_entry) GOTO(label, rc); \ } \ } -#if CONFIG_SNAP +#if CONFIG_SNAPFS /*snap macros*/ #define SMFS_PRE_COW(dir, dentry, op, name, rc, label) \ do { \ @@ -320,6 +319,9 @@ do { \ GOTO(label, rc); \ } \ } while(0) +extern int smfs_cow_init(struct super_block *sb); +extern int smfs_cow_cleanup(struct super_block *sb); +extern int smfs_init_snap_inode_info(struct inode *inode, int flags); #else #define SMFS_PRE_COW(dir, dentry, op, name, rc, label) #endif diff --git a/lustre/smfs/super.c b/lustre/smfs/super.c index b92eaf7..85a9586 100644 --- a/lustre/smfs/super.c +++ b/lustre/smfs/super.c @@ -239,6 +239,10 @@ void smfs_put_super(struct super_block *sb) cache_space_hook_exit(sb); if (SMFS_DO_REC(S2SMI(sb))) smfs_rec_cleanup(sb); +#if CONFIG_SNAPFS + if (SMFS_DO_COW(S2SMI(sb))) + smfs_cow_cleanup(sb); +#endif if (sb) sm_umount_cache(sb); return; @@ -297,7 +301,7 @@ static int smfs_fill_super(struct super_block *sb, sm_umount_cache(sb); GOTO(out_err, err=-EINVAL); } -#if CONFIG_SNAP +#if CONFIG_SNAPFS if (do_cow) smfs_cow_init(sb); #endif diff --git a/lustre/tests/lsnap.sh b/lustre/tests/lsnap.sh new file mode 100755 index 0000000..41af9e3 --- /dev/null +++ b/lustre/tests/lsnap.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +MDSDEV=smfs OSTDEV=smfs FSTYPE=smfs MDS_MOUNT_OPTS="kml,snap" OST_MOUNT_OPTS="kml,snap" \ +OSTSIZE=100000 MDSSIZE=50000 MDS_BACKFSTYPE=ext3 OST_BACKFSTYPE=ext3 \ +MDS_BACKDEV=/tmp/mds1-$(hostname) OST_BACKDEV=/tmp/ost1-$(hostname) sh llmount.sh diff --git a/lustre/utils/lctl.c b/lustre/utils/lctl.c index 4528b76..906fefe 100644 --- a/lustre/utils/lctl.c +++ b/lustre/utils/lctl.c @@ -244,6 +244,8 @@ command_t cmdlist[] = { "usage: lsync\n"}, {"cache_off", jt_obd_cache_off, 0, "usage: lsync\n"}, + /*snap operations*/ + {"snap_add", jt_obd_snap_add, 0, "usage: snap_add \n"}, /* Llog operations */ {"llog_catlist", jt_llog_catlist, 0, "list all catalog logs on current device.\n" diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index c1dbacd..903fb611 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -2094,7 +2094,26 @@ int jt_obd_cache_off(int argc, char **argv) rc); return rc; } +int jt_obd_snap_add(int argc, char **argv) +{ + struct obd_ioctl_data data; + int rc = 0; + + if (argc != 2) + return CMD_HELP; + IOC_INIT(data); + + data.ioc_inllen1 = strlen(argv[1]) + 1; + data.ioc_inlbuf1 = argv[1]; + IOC_PACK(argv[0], data); + + rc = l_ioctl(OBD_DEV_ID, OBD_IOC_SNAP_ADD, buf); + + if (rc) + fprintf(stderr, "OBD_IOC_SNAP_ADD failed: rc=%d\n", rc); + return rc; +} static void signal_server(int sig) { if (sig == SIGINT) { -- 1.8.3.1