From: adilger Date: Thu, 26 Dec 2002 10:29:36 +0000 (+0000) Subject: Damn CVS ate my nice long comment... X-Git-Tag: v1_7_100~1^248~134 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=4239c77f31e33ef762daec0f6c5a18daea9c1833;p=fs%2Flustre-release.git Damn CVS ate my nice long comment... Changes related to "fast" LOV stripe MD storage on the MDS: - Store small MD data inside the inode to avoid an extra seek. We don't need the super-hack of overloading the inode delete method like we did before, because we don't store the file size on the MDS any more, which means we don't truncate the fake blocks from the file on unlink. - Don't send size updates to MDS to avoid needless RPC and also avoid messing with MD data in inode per above. - Reduce MDS MD size by removing redundant fields and reducing the size of others, so that it is more likely we can fit this data into the inode. We can use the lmm_magic field to determine different stripe types, which will probably need different data fields anyways. This changes the ioctl interface, so I probably should create a lov_user_md struct again, now that lov_setstripe() iocontrol exists. - Pack MDS MD data only up to the last-allocated OST index, to make it smaller. - Change lov_create() OST selection code (per bug 470). This wasn't strictly related to this change, but it was in my tree and overlapping and I didn't want to re-do the changes. It seems to work, and it will help us handle errors that happen just at the wrong time (and also OSTs with no space/objs). - Check MD input data more carefully. --- diff --git a/lustre/obdclass/fsfilt_extN.c b/lustre/obdclass/fsfilt_extN.c index 9b5a1f9..98404dd 100644 --- a/lustre/obdclass/fsfilt_extN.c +++ b/lustre/obdclass/fsfilt_extN.c @@ -234,6 +234,31 @@ static int fsfilt_extN_setattr(struct dentry *dentry, void *handle, int rc; lock_kernel(); + + /* A _really_ horrible hack to avoid removing the data stored + * in the block pointers; this is really the "small" stripe MD data. + * We can avoid further hackery by virtue of the MDS file size being + * zero all the time (which doesn't invoke block truncate at unlink + * time), so we assert we never change the MDS file size from zero. + */ + if (iattr->ia_valid & ATTR_SIZE) { + CERROR("hmm, setting %*s file size to "LPU64"\n", + dentry->d_name.len, dentry->d_name.name, iattr->ia_size); + LASSERT(iattr->ia_size == 0); +#if 0 + /* ATTR_SIZE would invoke truncate: clear it */ + iattr->ia_valid &= ~ATTR_SIZE; + inode->i_size = iattr->ia_size; + + /* make sure _something_ gets set - so new inode + * goes to disk (probably won't work over XFS + */ + if (!iattr->ia_valid & ATTR_MODE) { + iattr->ia_valid |= ATTR_MODE; + iattr->ia_mode = inode->i_mode; + } +#endif + } if (inode->i_op->setattr) rc = inode->i_op->setattr(dentry, iattr); else @@ -249,29 +274,58 @@ static int fsfilt_extN_set_md(struct inode *inode, void *handle, { int rc; - down(&inode->i_sem); - lock_kernel(); - rc = extN_xattr_set(handle, inode, EXTN_XATTR_INDEX_LUSTRE, - XATTR_LUSTRE_MDS_OBJID, lmm, lmm_size, 0); - unlock_kernel(); - up(&inode->i_sem); + /* Nasty hack city - store stripe MD data in the block pointers if + * it will fit, because putting it in an EA currently kills the MDS + * performance. We'll fix this with "fast EAs" in the future. + */ + if (lmm_size <= sizeof(EXTN_I(inode)->i_data) - + sizeof(EXTN_I(inode)->i_data[0])) { + /* XXX old_size is debugging only */ + int old_size = EXTN_I(inode)->i_data[0]; + if (old_size != 0) { + LASSERT(old_size < sizeof(EXTN_I(inode)->i_data)); + CERROR("setting EA on %lu again... interesting\n", + inode->i_ino); + } - if (rc) { + EXTN_I(inode)->i_data[0] = cpu_to_le32(lmm_size); + memcpy(&EXTN_I(inode)->i_data[1], lmm, lmm_size); + mark_inode_dirty(inode); + return 0; + } else { + down(&inode->i_sem); + lock_kernel(); + rc = extN_xattr_set(handle, inode, EXTN_XATTR_INDEX_LUSTRE, + XATTR_LUSTRE_MDS_OBJID, lmm, lmm_size, 0); + unlock_kernel(); + up(&inode->i_sem); + } + + if (rc) CERROR("error adding MD data to inode %lu: rc = %d\n", inode->i_ino, rc); - if (rc != -ENOSPC) LBUG(); - } return rc; } -static int fsfilt_extN_get_md(struct inode *inode, void *lmm, int size) +static int fsfilt_extN_get_md(struct inode *inode, void *lmm, int lmm_size) { int rc; + if (EXTN_I(inode)->i_data[0]) { + int size = le32_to_cpu(EXTN_I(inode)->i_data[0]); + LASSERT(size < sizeof(EXTN_I(inode)->i_data)); + if (lmm) { + if (size > lmm_size) + return -ERANGE; + memcpy(lmm, &EXTN_I(inode)->i_data[1], size); + } + return size; + } + down(&inode->i_sem); lock_kernel(); rc = extN_xattr_get(inode, EXTN_XATTR_INDEX_LUSTRE, - XATTR_LUSTRE_MDS_OBJID, lmm, size); + XATTR_LUSTRE_MDS_OBJID, lmm, lmm_size); unlock_kernel(); up(&inode->i_sem); @@ -282,7 +336,7 @@ static int fsfilt_extN_get_md(struct inode *inode, void *lmm, int size) if (rc < 0) { CDEBUG(D_INFO, "error getting EA %s from inode %lu: " "rc = %d\n", XATTR_LUSTRE_MDS_OBJID, inode->i_ino, rc); - memset(lmm, 0, size); + memset(lmm, 0, lmm_size); return (rc == -ENODATA) ? 0 : rc; }