X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fobdclass%2Fdt_object.c;h=16312eb77614f3f851095830aeae24fcc640fd0a;hb=e5f552b70dccbd2fdf21ec7b7053a01bcbe062c2;hp=61b2768ea94189df8cb4f872e8f632f501fec3bc;hpb=98060d83459ba10409f295898f0ec917f938b4d3;p=fs%2Flustre-release.git diff --git a/lustre/obdclass/dt_object.c b/lustre/obdclass/dt_object.c index 61b2768..16312eb 100644 --- a/lustre/obdclass/dt_object.c +++ b/lustre/obdclass/dt_object.c @@ -215,22 +215,25 @@ EXPORT_SYMBOL(dt_lookup_dir); /* this differs from dt_locate by top_dev as parameter * but not one from lu_site */ struct dt_object *dt_locate_at(const struct lu_env *env, - struct dt_device *dev, const struct lu_fid *fid, - struct lu_device *top_dev) + struct dt_device *dev, + const struct lu_fid *fid, + struct lu_device *top_dev, + const struct lu_object_conf *conf) { - struct lu_object *lo, *n; - ENTRY; + struct lu_object *lo; + struct lu_object *n; - lo = lu_object_find_at(env, top_dev, fid, NULL); + lo = lu_object_find_at(env, top_dev, fid, conf); if (IS_ERR(lo)) - return (void *)lo; + return ERR_PTR(PTR_ERR(lo)); LASSERT(lo != NULL); - cfs_list_for_each_entry(n, &lo->lo_header->loh_layers, lo_linkage) { + list_for_each_entry(n, &lo->lo_header->loh_layers, lo_linkage) { if (n->lo_dev == &dev->dd_lu_dev) return container_of0(n, struct dt_object, do_lu); } + return ERR_PTR(-ENOENT); } EXPORT_SYMBOL(dt_locate_at); @@ -564,6 +567,17 @@ EXPORT_SYMBOL(dt_directory_features); const struct dt_index_features dt_otable_features; EXPORT_SYMBOL(dt_otable_features); +/* lfsck orphan */ +const struct dt_index_features dt_lfsck_orphan_features = { + .dif_flags = 0, + .dif_keysize_min = sizeof(struct lu_fid), + .dif_keysize_max = sizeof(struct lu_fid), + .dif_recsize_min = sizeof(struct lu_orphan_rec), + .dif_recsize_max = sizeof(struct lu_orphan_rec), + .dif_ptrsize = 4 +}; +EXPORT_SYMBOL(dt_lfsck_orphan_features); + /* lfsck */ const struct dt_index_features dt_lfsck_features = { .dif_flags = DT_IND_UPDATE, @@ -627,6 +641,8 @@ static inline const struct dt_index_features *dt_index_feat_select(__u64 seq, /* slave index should be a regular file */ return ERR_PTR(-ENOENT); return &dt_quota_slv_features; + } else if (seq == FID_SEQ_LAYOUT_RBTREE){ + return &dt_lfsck_orphan_features; } else if (seq >= FID_SEQ_NORMAL) { /* object is part of the namespace, verify that it is a * directory */ @@ -808,7 +824,7 @@ int dt_index_walk(const struct lu_env *env, struct dt_object *obj, int i; LASSERT(pageidx < rdpg->rp_npages); - lp = cfs_kmap(rdpg->rp_pages[pageidx]); + lp = kmap(rdpg->rp_pages[pageidx]); /* fill lu pages */ for (i = 0; i < LU_PAGE_COUNT; i++, lp++, nob -= LU_PAGE_SIZE) { @@ -822,7 +838,7 @@ int dt_index_walk(const struct lu_env *env, struct dt_object *obj, /* end of index */ break; } - cfs_kunmap(rdpg->rp_pages[i]); + kunmap(rdpg->rp_pages[i]); } iops->put(env, it); @@ -867,8 +883,9 @@ int dt_index_read(const struct lu_env *env, struct dt_device *dev, * time being */ RETURN(-EOPNOTSUPP); - if (!fid_is_quota(&ii->ii_fid)) - /* block access to all local files except quota files */ + if (!fid_is_quota(&ii->ii_fid) && !fid_is_layout_rbtree(&ii->ii_fid)) + /* Block access to all local files except quota files and + * layout rbtree. */ RETURN(-EPERM); /* lookup index object subject to the transfer */ @@ -914,13 +931,16 @@ int dt_index_read(const struct lu_env *env, struct dt_device *dev, /* key isn't necessarily unique */ ii->ii_flags |= II_FL_NONUNQ; - dt_read_lock(env, obj, 0); - /* fetch object version before walking the index */ - ii->ii_version = dt_version_get(env, obj); + if (!fid_is_layout_rbtree(&ii->ii_fid)) { + dt_read_lock(env, obj, 0); + /* fetch object version before walking the index */ + ii->ii_version = dt_version_get(env, obj); + } /* walk the index and fill lu_idxpages with key/record pairs */ rc = dt_index_walk(env, obj, rdpg, dt_index_page_build ,ii); - dt_read_unlock(env, obj); + if (!fid_is_layout_rbtree(&ii->ii_fid)) + dt_read_unlock(env, obj); if (rc == 0) { /* index is empty */ @@ -936,7 +956,7 @@ out: EXPORT_SYMBOL(dt_index_read); #ifdef LPROCFS - +#ifndef HAVE_ONLY_PROCFS_SEQ int lprocfs_dt_rd_blksize(char *page, char **start, off_t off, int count, int *eof, void *data) { @@ -944,9 +964,9 @@ int lprocfs_dt_rd_blksize(char *page, char **start, off_t off, struct obd_statfs osfs; int rc = dt_statfs(NULL, dt, &osfs); - if (rc != 0) { + if (rc == 0) { *eof = 1; - rc = snprintf(page, count, "%d\n", + rc = snprintf(page, count, "%u\n", (unsigned) osfs.os_bsize); } @@ -961,7 +981,7 @@ int lprocfs_dt_rd_kbytestotal(char *page, char **start, off_t off, struct obd_statfs osfs; int rc = dt_statfs(NULL, dt, &osfs); - if (rc != 0) { + if (rc == 0) { __u32 blk_size = osfs.os_bsize >> 10; __u64 result = osfs.os_blocks; @@ -983,7 +1003,7 @@ int lprocfs_dt_rd_kbytesfree(char *page, char **start, off_t off, struct obd_statfs osfs; int rc = dt_statfs(NULL, dt, &osfs); - if (rc != 0) { + if (rc == 0) { __u32 blk_size = osfs.os_bsize >> 10; __u64 result = osfs.os_bfree; @@ -1005,7 +1025,7 @@ int lprocfs_dt_rd_kbytesavail(char *page, char **start, off_t off, struct obd_statfs osfs; int rc = dt_statfs(NULL, dt, &osfs); - if (rc != 0) { + if (rc == 0) { __u32 blk_size = osfs.os_bsize >> 10; __u64 result = osfs.os_bavail; @@ -1027,7 +1047,7 @@ int lprocfs_dt_rd_filestotal(char *page, char **start, off_t off, struct obd_statfs osfs; int rc = dt_statfs(NULL, dt, &osfs); - if (rc != 0) { + if (rc == 0) { *eof = 1; rc = snprintf(page, count, LPU64"\n", osfs.os_files); } @@ -1043,7 +1063,7 @@ int lprocfs_dt_rd_filesfree(char *page, char **start, off_t off, struct obd_statfs osfs; int rc = dt_statfs(NULL, dt, &osfs); - if (rc != 0) { + if (rc == 0) { *eof = 1; rc = snprintf(page, count, LPU64"\n", osfs.os_ffree); } @@ -1051,5 +1071,99 @@ int lprocfs_dt_rd_filesfree(char *page, char **start, off_t off, return rc; } EXPORT_SYMBOL(lprocfs_dt_rd_filesfree); +#endif + +int lprocfs_dt_blksize_seq_show(struct seq_file *m, void *v) +{ + struct dt_device *dt = m->private; + struct obd_statfs osfs; + + int rc = dt_statfs(NULL, dt, &osfs); + if (rc == 0) + seq_printf(m, "%u\n", (unsigned) osfs.os_bsize); + return rc; +} +EXPORT_SYMBOL(lprocfs_dt_blksize_seq_show); + +int lprocfs_dt_kbytestotal_seq_show(struct seq_file *m, void *v) +{ + struct dt_device *dt = m->private; + struct obd_statfs osfs; + + int rc = dt_statfs(NULL, dt, &osfs); + if (rc == 0) { + __u32 blk_size = osfs.os_bsize >> 10; + __u64 result = osfs.os_blocks; + + while (blk_size >>= 1) + result <<= 1; + + seq_printf(m, LPU64"\n", result); + } + return rc; +} +EXPORT_SYMBOL(lprocfs_dt_kbytestotal_seq_show); + +int lprocfs_dt_kbytesfree_seq_show(struct seq_file *m, void *v) +{ + struct dt_device *dt = m->private; + struct obd_statfs osfs; + + int rc = dt_statfs(NULL, dt, &osfs); + if (rc == 0) { + __u32 blk_size = osfs.os_bsize >> 10; + __u64 result = osfs.os_bfree; + + while (blk_size >>= 1) + result <<= 1; + + seq_printf(m, LPU64"\n", result); + } + return rc; +} +EXPORT_SYMBOL(lprocfs_dt_kbytesfree_seq_show); + +int lprocfs_dt_kbytesavail_seq_show(struct seq_file *m, void *v) +{ + struct dt_device *dt = m->private; + struct obd_statfs osfs; + + int rc = dt_statfs(NULL, dt, &osfs); + if (rc == 0) { + __u32 blk_size = osfs.os_bsize >> 10; + __u64 result = osfs.os_bavail; + + while (blk_size >>= 1) + result <<= 1; + + seq_printf(m, LPU64"\n", result); + } + return rc; +} +EXPORT_SYMBOL(lprocfs_dt_kbytesavail_seq_show); + +int lprocfs_dt_filestotal_seq_show(struct seq_file *m, void *v) +{ + struct dt_device *dt = m->private; + struct obd_statfs osfs; + + int rc = dt_statfs(NULL, dt, &osfs); + if (rc == 0) + seq_printf(m, LPU64"\n", osfs.os_files); + return rc; +} +EXPORT_SYMBOL(lprocfs_dt_filestotal_seq_show); + +int lprocfs_dt_filesfree_seq_show(struct seq_file *m, void *v) +{ + struct dt_device *dt = m->private; + struct obd_statfs osfs; + + int rc = dt_statfs(NULL, dt, &osfs); + if (rc == 0) + seq_printf(m, LPU64"\n", osfs.os_ffree); + return rc; +} +EXPORT_SYMBOL(lprocfs_dt_filesfree_seq_show); #endif /* LPROCFS */