From c1e963d3f9f0043392638aca62b04b275b52bad6 Mon Sep 17 00:00:00 2001 From: adilger Date: Fri, 29 Mar 2002 12:02:00 +0000 Subject: [PATCH] Set a flag in the inode if we have stored the objid there, so we know when we should clear it. Also make clear_inode() the default cl_delete_inode method so we don't have to do an extra check for it. In the end, I think that the objid issue is not a source of any problems, because ext3_delete() will only call ext3_truncate() if i_blocks is non-zero, and it isn't (this is why we weren't seeing any errors from ext3 trying to truncate "blocks" that are not allocated). --- lustre/mds/mds_ext2.c | 11 ++++++----- lustre/mds/mds_ext3.c | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lustre/mds/mds_ext2.c b/lustre/mds/mds_ext2.c index f2a24b2..883295d4 100644 --- a/lustre/mds/mds_ext2.c +++ b/lustre/mds/mds_ext2.c @@ -56,9 +56,11 @@ static int mds_ext2_setattr(struct inode *inode, void *handle, * FIXME: nasty hack - store the object id in the first two * direct block spots. This should be done with EAs... */ +#define EXT2_OBJID_FL 0x40000000 static int mds_ext2_set_objid(struct inode *inode, void *handle, obd_id id) { memcpy(inode->u.ext2_i.i_data, &id, sizeof(id)); + inode->u.ext2_i.i_flags |= EXT2_OBJID_FL; return 0; } @@ -78,13 +80,12 @@ static ssize_t mds_ext2_readpage(struct file *file, char *buf, size_t count, struct mds_fs_operations mds_ext2_fs_ops; -void mds_ext2_delete_inode(struct inode * inode) +void mds_ext2_delete_inode(struct inode *inode) { - if (!S_ISDIR(inode->i_mode)) + if (inode->u.ext2_i.i_flags & EXT2_OBJID_FL) mds_ext2_set_objid(inode, NULL, 0); - if (mds_ext2_fs_ops.cl_delete_inode) - mds_ext2_fs_ops.cl_delete_inode(inode); + mds_ext2_fs_ops.cl_delete_inode(inode); } struct mds_fs_operations mds_ext2_fs_ops = { @@ -95,5 +96,5 @@ struct mds_fs_operations mds_ext2_fs_ops = { fs_get_objid: mds_ext2_get_objid, fs_readpage: mds_ext2_readpage, fs_delete_inode:mds_ext2_delete_inode, - cl_delete_inode:NULL, + cl_delete_inode:clear_inode, }; diff --git a/lustre/mds/mds_ext3.c b/lustre/mds/mds_ext3.c index de62b4f..6a9cd50 100644 --- a/lustre/mds/mds_ext3.c +++ b/lustre/mds/mds_ext3.c @@ -79,10 +79,11 @@ static int mds_ext3_setattr(struct inode *inode, void *handle, * FIXME: nasty hack - store the object id in the first two * direct block spots. This should be done with EAs... */ +#define EXT3_OBJID_FL 0x40000000 static int mds_ext3_set_objid(struct inode *inode, void *handle, obd_id id) { memcpy(&EXT3_I(inode)->i_data, &id, sizeof(id)); - + EXT3_I(inode)->i_flags |= EXT3_OBJID_FL; return 0; } @@ -124,10 +125,10 @@ void mds_ext3_delete_inode(struct inode * inode) { void *handle; - if (!S_ISDIR(inode->i_mode)) { + if (EXT3_I(inode)->i_flags & EXT3_OBJID_FL) { handle = mds_ext3_start(inode, MDS_FSOP_UNLINK); - if (!IS_ERR(handle)) { + if (IS_ERR(handle)) { CERROR("unable to start transaction"); EXIT; return; @@ -140,7 +141,7 @@ void mds_ext3_delete_inode(struct inode * inode) if (mds_ext3_commit(inode, handle)) CERROR("error closing handle on %ld\n", inode->i_ino); - } else if (mds_ext3_fs_ops.cl_delete_inode) + } else mds_ext3_fs_ops.cl_delete_inode(inode); } @@ -152,5 +153,5 @@ struct mds_fs_operations mds_ext3_fs_ops = { fs_get_objid: mds_ext3_get_objid, fs_readpage: mds_ext3_readpage, fs_delete_inode:mds_ext3_delete_inode, - cl_delete_inode:NULL, + cl_delete_inode:clear_inode, }; -- 1.8.3.1