From bfdc6e992503046348306c24942efda3661e5c91 Mon Sep 17 00:00:00 2001 From: yury Date: Mon, 21 Jun 2004 11:03:06 +0000 Subject: [PATCH] - added md_delete_object() and lmv_delete_object(). This is needed to remove LMV object on delete_inode() call. - small fixes in md_*() methods (added missed ENTRY). --- lustre/include/linux/obd.h | 1 + lustre/include/linux/obd_class.h | 24 ++++++++++++++++++++++-- lustre/llite/llite_internal.h | 1 + lustre/llite/llite_lib.c | 18 ++++++++++++++++++ lustre/llite/super.c | 2 +- lustre/lmv/lmv_internal.h | 2 +- lustre/lmv/lmv_obd.c | 14 ++++++++++++++ lustre/lmv/lmv_objmgr.c | 2 +- 8 files changed, 59 insertions(+), 5 deletions(-) diff --git a/lustre/include/linux/obd.h b/lustre/include/linux/obd.h index fd3f196..c8727d7 100644 --- a/lustre/include/linux/obd.h +++ b/lustre/include/linux/obd.h @@ -819,6 +819,7 @@ struct md_ops { int repoff); int (*m_set_lock_data)(struct obd_export *exp, __u64 *l, void *data); + int (*m_delete_object)(struct obd_export *, struct ll_fid *); /* * NOTE: If adding ops, add another LPROCFS_OBD_OP_INIT() line * to lprocfs_alloc_obd_stats() in obdclass/lprocfs_status.c. diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h index d78158a..4af2936 100644 --- a/lustre/include/linux/obd_class.h +++ b/lustre/include/linux/obd_class.h @@ -1122,11 +1122,31 @@ static inline int md_getstatus(struct obd_export *exp, struct ll_fid *fid) RETURN(rc); } +/* this function notifies MDC, that inode described by @fid gets removed from + * memory.*/ +static inline int md_delete_object(struct obd_export *exp, + struct ll_fid *fid) +{ + int rc; + ENTRY; + + /* as this method only notifies MDC that inode gets deleted, we can + * return zero if method is not implemented, this means, that OBD does + * not need such a notification. */ + if (MDP(exp->exp_obd, delete_object) == NULL) + RETURN(0); + + MD_COUNTER_INCREMENT(exp->exp_obd, delete_object); + rc = MDP(exp->exp_obd, delete_object)(exp, fid); + RETURN(rc); +} + static inline int md_getattr(struct obd_export *exp, struct ll_fid *fid, unsigned long valid, unsigned int ea_size, struct ptlrpc_request **request) { int rc; + ENTRY; EXP_CHECK_MD_OP(exp, getattr); MD_COUNTER_INCREMENT(exp->exp_obd, getattr); rc = MDP(exp->exp_obd, getattr)(exp, fid, valid, ea_size, request); @@ -1323,8 +1343,8 @@ static inline int md_unlink(struct obd_export *exp, struct mdc_op_data *data, RETURN(rc); } -static inline struct obd_device * md_get_real_obd(struct obd_export *exp, - char *name, int len) +static inline struct obd_device *md_get_real_obd(struct obd_export *exp, + char *name, int len) { ENTRY; if (MDP(exp->exp_obd, get_real_obd) == NULL) diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 25878b9..2cca168 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -215,6 +215,7 @@ void ll_update_inode(struct inode *inode, struct lustre_md *); int it_disposition(struct lookup_intent *it, int flag); void it_set_disposition(struct lookup_intent *it, int flag); void ll_read_inode2(struct inode *inode, void *opaque); +void ll_delete_inode(struct inode *inode); int ll_iocontrol(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg); void ll_umount_begin(struct super_block *sb); diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 26dec71..e2d9d18 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -1334,6 +1334,24 @@ void ll_read_inode2(struct inode *inode, void *opaque) } } +void ll_delete_inode(struct inode *inode) +{ + int rc; + struct ll_fid fid; + struct ll_sb_info *sbi = ll_i2sbi(inode); + ENTRY; + + ll_inode2fid(&fid, inode); + + rc = md_delete_object(sbi->ll_mdc_exp, &fid); + if (rc) { + CERROR("md_delete_object() failed, error %d.\n", + rc); + } + + EXIT; +} + int ll_iocontrol(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { diff --git a/lustre/llite/super.c b/lustre/llite/super.c index c70a998..13dd060 100644 --- a/lustre/llite/super.c +++ b/lustre/llite/super.c @@ -79,7 +79,7 @@ struct super_operations lustre_super_operations = { .read_inode2 = ll_read_inode2, .clear_inode = ll_clear_inode, -// .delete_inode = ll_delete_inode, + .delete_inode = ll_delete_inode, .put_super = lustre_put_super, .statfs = ll_statfs, .umount_begin = ll_umount_begin, diff --git a/lustre/lmv/lmv_internal.h b/lustre/lmv/lmv_internal.h index d4623db..35d4ab3 100644 --- a/lustre/lmv/lmv_internal.h +++ b/lustre/lmv/lmv_internal.h @@ -63,7 +63,7 @@ struct lmv_obj *lmv_create_obj(struct obd_export *exp, struct ll_fid *fid, struct mea *mea); -int lmv_destroy_obj(struct obd_export *exp, struct ll_fid *fid); +int lmv_delete_obj(struct obd_export *exp, struct ll_fid *fid); int lmv_intent_lock(struct obd_export *, struct ll_uctxt *, struct ll_fid *, const char *, int, void *, int, diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 681893d..08c4479 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -1283,6 +1283,19 @@ int lmv_unlink_slaves(struct obd_export *exp, struct mdc_op_data *data, RETURN(rc); } +int lmv_delete_object(struct obd_export *exp, struct ll_fid *fid) +{ + ENTRY; + + if (!lmv_delete_obj(exp, fid)) { + CWARN("Object %lu/%lu/%lu is not found.\n", + (unsigned long)fid->mds, (unsigned long)fid->id, + (unsigned long)fid->generation); + } + + RETURN(0); +} + int lmv_unlink(struct obd_export *exp, struct mdc_op_data *data, struct ptlrpc_request **request) { @@ -1691,6 +1704,7 @@ struct md_ops lmv_md_ops = { .m_unlink = lmv_unlink, .m_get_real_obd = lmv_get_real_obd, .m_valid_attrs = lmv_valid_attrs, + .m_delete_object = lmv_delete_object, }; int __init lmv_init(void) diff --git a/lustre/lmv/lmv_objmgr.c b/lustre/lmv/lmv_objmgr.c index 1deb5f3..3670697 100644 --- a/lustre/lmv/lmv_objmgr.c +++ b/lustre/lmv/lmv_objmgr.c @@ -336,7 +336,7 @@ cleanup: * this case it will be marked as "freeing" and will not be accessible anymore * for subsequent callers of lmv_grab_obj(). */ int -lmv_destroy_obj(struct obd_export *exp, struct ll_fid *fid) +lmv_delete_obj(struct obd_export *exp, struct ll_fid *fid) { struct obd_device *obd = exp->exp_obd; struct lmv_obj *obj; -- 1.8.3.1