Commit
07660ad33a7d1 can give more warning message when directory
size exceeds limitation. But some variables that are allocated
on stack are unnecessary and may cause overflow.
Further more, the "osd_thread_info::oti_dev" is obsolete, should
not be used any more. The fid_seq_is_mdt0() is used against zero
FID, will be replaced by checking whether the device is for MDT0.
Signed-off-by: Fan Yong <fan.yong@intel.com>
Change-Id: Idfe2a4546535b3863e84ce5753b8a86c369dadae
Reviewed-on: http://review.whamcloud.com/22307
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Yang Sheng <yang.sheng@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
dentry = osd_child_dentry_by_inode(env, parent->d_inode,
name, strlen(name));
mutex_lock(&parent->d_inode->i_mutex);
dentry = osd_child_dentry_by_inode(env, parent->d_inode,
name, strlen(name));
mutex_lock(&parent->d_inode->i_mutex);
- rc = osd_ldiskfs_add_entry(info, oh->ot_handle, dentry,
+ rc = osd_ldiskfs_add_entry(info, osd, oh->ot_handle, dentry,
obj->oo_inode, NULL);
CDEBUG(D_INODE, "%s: add %s:%lu to remote parent %lu.\n", osd_name(osd),
name, obj->oo_inode->i_ino, parent->d_inode->i_ino);
obj->oo_inode, NULL);
CDEBUG(D_INODE, "%s: add %s:%lu to remote parent %lu.\n", osd_name(osd),
name, obj->oo_inode->i_ino, parent->d_inode->i_ino);
ll_vfs_dq_init(dir->d_inode);
mutex_lock(&dir->d_inode->i_mutex);
ll_vfs_dq_init(dir->d_inode);
mutex_lock(&dir->d_inode->i_mutex);
- rc = osd_ldiskfs_add_entry(info, th, child, inode, NULL);
+ rc = osd_ldiskfs_add_entry(info, osd, th, child, inode, NULL);
mutex_unlock(&dir->d_inode->i_mutex);
RETURN(rc);
mutex_unlock(&dir->d_inode->i_mutex);
RETURN(rc);
if (rc != 0)
GOTO(unlock, rc);
if (rc != 0)
GOTO(unlock, rc);
- rc = osd_ldiskfs_add_entry(info, jh, tgt_child, inode, NULL);
+ rc = osd_ldiskfs_add_entry(info, osd, jh, tgt_child, inode, NULL);
-int osd_ldiskfs_add_entry(struct osd_thread_info *info,
+int osd_ldiskfs_add_entry(struct osd_thread_info *info, struct osd_device *osd,
handle_t *handle, struct dentry *child,
struct inode *inode, struct htree_lock *hlock)
{
handle_t *handle, struct dentry *child,
struct inode *inode, struct htree_lock *hlock)
{
rc = __ldiskfs_add_entry(handle, child, inode, hlock);
if (rc == -ENOBUFS || rc == -ENOSPC) {
rc = __ldiskfs_add_entry(handle, child, inode, hlock);
if (rc == -ENOBUFS || rc == -ENOSPC) {
- char fidbuf[FID_LEN + 1];
- struct lustre_mdt_attrs lma;
- struct lu_fid fid = { };
- char *errstr;
- struct dentry *p_dentry = child->d_parent;
-
- rc2 = osd_get_lma(info, p_dentry->d_inode, p_dentry,
- &lma);
+ struct lustre_mdt_attrs *lma = &info->oti_mdt_attrs;
+ struct inode *parent = child->d_parent->d_inode;
+ struct lu_fid *fid = NULL;
+
+ rc2 = osd_get_lma(info, parent, child->d_parent, lma);
- fid = lma.lma_self_fid;
- snprintf(fidbuf, sizeof(fidbuf), DFID, PFID(&fid));
+ fid = &lma->lma_self_fid;
} else if (rc2 == -ENODATA) {
} else if (rc2 == -ENODATA) {
- if (unlikely(p_dentry->d_inode ==
- inode->i_sb->s_root->d_inode))
- lu_local_obj_fid(&fid, OSD_FS_ROOT_OID);
- else if (info->oti_dev && !info->oti_dev->od_is_ost &&
- fid_seq_is_mdt0(fid_seq(&fid)))
- lu_igif_build(&fid, p_dentry->d_inode->i_ino,
- p_dentry->d_inode->i_generation);
- snprintf(fidbuf, sizeof(fidbuf), DFID, PFID(&fid));
- } else {
- snprintf(fidbuf, FID_LEN, "%s", "unknown");
+ if (unlikely(parent == inode->i_sb->s_root->d_inode)) {
+ fid = &info->oti_fid3;
+ lu_local_obj_fid(fid, OSD_FS_ROOT_OID);
+ } else if (!osd->od_is_ost && osd->od_index == 0) {
+ fid = &info->oti_fid3;
+ lu_igif_build(fid, parent->i_ino,
+ parent->i_generation);
+ }
- if (rc == -ENOSPC)
- errstr = "has reached";
+ if (fid != NULL)
+ CWARN("%s: directory (inode: %lu, FID: "DFID") %s "
+ "maximum entry limit\n",
+ osd_name(osd), parent->i_ino, PFID(fid),
+ rc == -ENOSPC ? "has reached" : "is approaching");
- errstr = "is approaching";
- CWARN("%.16s: directory (inode: %lu FID: %s) %s maximum entry limit\n",
- LDISKFS_SB(inode->i_sb)->s_es->s_volume_name,
- p_dentry->d_inode->i_ino, fidbuf, errstr);
+ CWARN("%s: directory (inode: %lu, FID: unknown) %s "
+ "maximum entry limit\n",
+ osd_name(osd), parent->i_ino,
+ rc == -ENOSPC ? "has reached" : "is approaching");
+
/* ignore such error now */
if (rc == -ENOBUFS)
rc = 0;
}
/* ignore such error now */
if (rc == -ENOBUFS)
rc = 0;
}
child = osd_child_dentry_get(info->oti_env, pobj, name, strlen(name));
child->d_fsdata = (void *)ldp;
ll_vfs_dq_init(pobj->oo_inode);
child = osd_child_dentry_get(info->oti_env, pobj, name, strlen(name));
child->d_fsdata = (void *)ldp;
ll_vfs_dq_init(pobj->oo_inode);
- rc = osd_ldiskfs_add_entry(info, oth->ot_handle, child,
- cinode, hlock);
+ rc = osd_ldiskfs_add_entry(info, osd_obj2dev(pobj), oth->ot_handle,
+ child, cinode, hlock);
if (rc == 0 && OBD_FAIL_CHECK(OBD_FAIL_LFSCK_BAD_TYPE)) {
struct ldiskfs_dir_entry_2 *de;
struct buffer_head *bh;
if (rc == 0 && OBD_FAIL_CHECK(OBD_FAIL_LFSCK_BAD_TYPE)) {
struct ldiskfs_dir_entry_2 *de;
struct buffer_head *bh;
-osd_dirent_reinsert(const struct lu_env *env, handle_t *jh,
- struct dentry *dentry, const struct lu_fid *fid,
- struct buffer_head *bh, struct ldiskfs_dir_entry_2 *de,
- struct htree_lock *hlock, int dot_dotdot)
+osd_dirent_reinsert(const struct lu_env *env, struct osd_device *dev,
+ handle_t *jh, struct dentry *dentry,
+ const struct lu_fid *fid, struct buffer_head *bh,
+ struct ldiskfs_dir_entry_2 *de, struct htree_lock *hlock,
+ int dot_dotdot)
{
struct inode *dir = dentry->d_parent->d_inode;
struct inode *inode = dentry->d_inode;
{
struct inode *dir = dentry->d_parent->d_inode;
struct inode *inode = dentry->d_inode;
osd_get_ldiskfs_dirent_param(ldp, fid);
dentry->d_fsdata = (void *)ldp;
ll_vfs_dq_init(dir);
osd_get_ldiskfs_dirent_param(ldp, fid);
dentry->d_fsdata = (void *)ldp;
ll_vfs_dq_init(dir);
- rc = osd_ldiskfs_add_entry(info, jh, dentry, inode, hlock);
+ rc = osd_ldiskfs_add_entry(info, dev, jh, dentry, inode, hlock);
/* It is too bad, we cannot reinsert the name entry back.
* That means we lose it! */
if (rc != 0)
/* It is too bad, we cannot reinsert the name entry back.
* That means we lose it! */
if (rc != 0)
*fid = lma->lma_self_fid;
dirty = true;
/* Update the FID-in-dirent. */
*fid = lma->lma_self_fid;
dirty = true;
/* Update the FID-in-dirent. */
- rc = osd_dirent_reinsert(env, jh, dentry, fid, bh, de,
- hlock, dot_dotdot);
+ rc = osd_dirent_reinsert(env, dev, jh, dentry, fid,
+ bh, de, hlock, dot_dotdot);
if (rc == 0)
*attr |= LUDA_REPAIR;
else
if (rc == 0)
*attr |= LUDA_REPAIR;
else
*fid = lma->lma_self_fid;
dirty = true;
/* Append the FID-in-dirent. */
*fid = lma->lma_self_fid;
dirty = true;
/* Append the FID-in-dirent. */
- rc = osd_dirent_reinsert(env, jh, dentry, fid, bh, de,
- hlock, dot_dotdot);
+ rc = osd_dirent_reinsert(env, dev, jh, dentry, fid,
+ bh, de, hlock, dot_dotdot);
if (rc == 0)
*attr |= LUDA_REPAIR;
else
if (rc == 0)
*attr |= LUDA_REPAIR;
else
lu_igif_build(fid, inode->i_ino, inode->i_generation);
/* It is probably IGIF object. Only aappend the
* FID-in-dirent. OI scrub will process FID-in-LMA. */
lu_igif_build(fid, inode->i_ino, inode->i_generation);
/* It is probably IGIF object. Only aappend the
* FID-in-dirent. OI scrub will process FID-in-LMA. */
- rc = osd_dirent_reinsert(env, jh, dentry, fid, bh, de,
- hlock, dot_dotdot);
+ rc = osd_dirent_reinsert(env, dev, jh, dentry, fid,
+ bh, de, hlock, dot_dotdot);
if (rc == 0)
*attr |= LUDA_UPGRADE;
else
if (rc == 0)
*attr |= LUDA_UPGRADE;
else
struct osd_mdobj_map {
struct dentry *omm_remote_parent;
};
struct osd_mdobj_map {
struct dentry *omm_remote_parent;
};
-int osd_ldiskfs_add_entry(struct osd_thread_info *info,
+int osd_ldiskfs_add_entry(struct osd_thread_info *info, struct osd_device *osd,
handle_t *handle, struct dentry *child,
struct inode *inode, struct htree_lock *hlock);
handle_t *handle, struct dentry *child,
struct inode *inode, struct htree_lock *hlock);
*/
struct timespec oti_time;
*/
struct timespec oti_time;
- /** osd_device reference, initialized in osd_trans_start() and
- used in osd_trans_stop() */
- struct osd_device *oti_dev;
-
/**
* following ipd and it structures are used for osd_index_iam_lookup()
* these are defined separately as we might do index operation
/**
* following ipd and it structures are used for osd_index_iam_lookup()
* these are defined separately as we might do index operation
feat->dif_ptrsize, feat->dif_recsize_max,
jh);
dentry = osd_child_dentry_by_inode(env, dir, name, strlen(name));
feat->dif_ptrsize, feat->dif_recsize_max,
jh);
dentry = osd_child_dentry_by_inode(env, dir, name, strlen(name));
- rc = osd_ldiskfs_add_entry(info, jh, dentry, inode, NULL);
+ rc = osd_ldiskfs_add_entry(info, osd, jh, dentry, inode, NULL);
ldiskfs_journal_stop(jh);
iput(inode);
return rc;
ldiskfs_journal_stop(jh);
iput(inode);
return rc;