int mdd_attr_get(const struct lu_env *env, struct md_object *obj,
struct md_attr *ma)
{
- int rc;
- ENTRY;
+ struct mdd_object *mdd_obj = md2mdd_obj(obj);
+ int rc;
- return mdd_la_get(env, md2mdd_obj(obj), &ma->ma_attr,
- mdd_object_capa(env, md2mdd_obj(obj)));
- RETURN(rc);
+ ENTRY;
+
+ rc = mdd_la_get(env, mdd_obj, &ma->ma_attr,
+ mdd_object_capa(env, md2mdd_obj(obj)));
+ if ((ma->ma_need & MA_INODE) != 0 && mdd_is_dead_obj(mdd_obj))
+ ma->ma_attr.la_nlink = 0;
+
+ RETURN(rc);
}
/*
}
run_test 31m "link to file: the same, non-existing, dir==============="
+test_31n() {
+ [ -e /proc/self/fd/173 ] && echo "skipping, fd 173 is in use" && return
+ touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
+ nlink=$(stat --format=%h $DIR/$tfile)
+ [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
+ exec 173<$DIR/$tfile
+ trap "exec 173<&-" EXIT
+ nlink=$(stat --dereference --format=%h /proc/self/fd/173)
+ [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
+ rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
+ nlink=$(stat --dereference --format=%h /proc/self/fd/173)
+ [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
+ exec 173<&-
+}
+run_test 31n "check link count of unlinked file"
+
cleanup_test32_mount() {
trap 0
$UMOUNT $DIR/$tdir/ext2-mountpoint