Lines Matching refs:ctx
391 static void InitDcacheLookupCtx(DcacheLookupCtx *ctx, const MetaBase &base, int fd)
393 ctx->fd = fd;
394 ctx->name = base.name;
395 ctx->bidx = 0;
396 ctx->page = nullptr;
397 ctx->hash = CloudDisk::CloudFileUtils::DentryHash(ctx->name);
400 static std::unique_ptr<HmdfsDentryGroup> FindDentryPage(uint64_t index, DcacheLookupCtx *ctx)
405 ssize_t size = FileUtils::ReadFile(ctx->fd, pos, DENTRYGROUP_SIZE, dentryBlk.get());
441 static HmdfsDentry *InLevel(uint32_t level, DcacheLookupCtx *ctx)
451 uint32_t bidx = GetBucketaddr(level, ctx->hash % nbucket) * BUCKET_BLOCKS;
455 auto dentryBlk = FindDentryPage(bidx, ctx);
460 de = FindInBlock(*dentryBlk, ctx->hash, ctx->name);
462 ctx->page = std::move(dentryBlk);
466 ctx->bidx = bidx;
486 static HmdfsDentry *FindDentry(DcacheLookupCtx *ctx)
488 uint32_t maxLevel = GetMaxLevel(ctx->fd);
490 HmdfsDentry *de = InLevel(level, ctx);
507 DcacheLookupCtx ctx;
508 InitDcacheLookupCtx(&ctx, base, fd_);
509 HmdfsDentry *de = FindDentry(&ctx);
515 uint32_t bitPos = (de - ctx.page->nsl);
518 BitOps::ClearBit(bitPos + i, ctx.page->bitmap);
521 off_t ipos = GetDentryGroupPos(ctx.bidx);
522 ssize_t size = FileUtils::WriteFile(fd_, ctx.page.get(), ipos, sizeof(HmdfsDentryGroup));
540 struct DcacheLookupCtx ctx;
541 InitDcacheLookupCtx(&ctx, base, fd_);
542 struct HmdfsDentry *de = FindDentry(&ctx);
566 struct DcacheLookupCtx ctx;
567 InitDcacheLookupCtx(&ctx, base, fd_);
568 struct HmdfsDentry *de = FindDentry(&ctx);
582 off_t ipos = GetDentryGroupPos(ctx.bidx);
583 ssize_t size = FileUtils::WriteFile(fd_, ctx.page.get(), ipos, sizeof(struct HmdfsDentryGroup));