Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D358175A81 for ; Mon, 27 Apr 2026 23:02:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777330924; cv=none; b=Pcy6S8MwupNVNF4pHq/qTCdqEnxTVSd1SDpQFXVSSFwZfvBh2a1KzskfCX92ajC6JHRNWezBR8b4YExoet5rc7DLTbDDx3uD2fsCyuKQ3pb7wu9jF5MJFCvBV0o63kZuqh4pwvdeeNCwY+3IOTNSY95HWi4ohQ64F0X5hJ/YaXI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777330924; c=relaxed/simple; bh=YGIBhKxzApH17RMUrv/wzF+lvBpHx9pFLkJdxIr1NbE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Si32yMvgkVsNG5hT2Ox55moKEypnxfUuys9x7m/wY2kG2DM8CA/2RVeX2KAYSXANH5b02fvbFbKPBEMqW1YpvOAHnD9o0MLZeF5o15PYfO1tClIu++YDdezoklxK/S/hbiSPspaVM81EobGpZQLqJEp79b7Oep06+juXLlR61ws= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=zabbo.net; spf=pass smtp.mailfrom=zabbo.net; dkim=pass (1024-bit key) header.d=zabbo.net header.i=@zabbo.net header.b=dNneh0B3; arc=none smtp.client-ip=209.85.216.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=zabbo.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zabbo.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=zabbo.net header.i=@zabbo.net header.b="dNneh0B3" Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-35d99031e4eso7448447a91.1 for ; Mon, 27 Apr 2026 16:02:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zabbo.net; s=google; t=1777330923; x=1777935723; darn=lists.linux.dev; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=OFQKCoDKyr5Wx6l5o4eaMfQrr0cSeflxhxXJRpVordg=; b=dNneh0B3dphehfc/rK6ICrK4wORIJC9CcUVPYt/nOp5TTKVvKyUPUMaPavxHuHc+Ge VRekelO6x39vGOT9be2/Pm1ln+HJ/5eO56JcG/786zz7lLNIXtvwkUk58YO2wBPyChFV W4jpMiwvZxNo7Ah00x7w7iFMqFlRTShFYc9zE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777330923; x=1777935723; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OFQKCoDKyr5Wx6l5o4eaMfQrr0cSeflxhxXJRpVordg=; b=eN5JVfIq38h1H8YewGkbAQEKE5L001RHLvKShw7OoE/Dvn4eBV1AueO3J0nQr9Qpd2 Zt6G9wZRN5tsbptFJPzkgW8GbRU0vUaWVwxbNakpdS96s8yIMvUeWHcgygsMRdaWPODD YPT62627aaM084gHFSTubPjr+cNdqO1X5ljdABsyZabw8CAa12DVEylr5jvLwpO6X6n2 HxMFfTsifnbJLzQhsFDB4TgYzqyN0z1+8GV7oC6j8vOcmhD075HS5VIAJiPw8RwFEmXE ncvpk4BQtLJc2SHxb5WhNV1e1ThbYFUW5xcIlsSGeEOwM5uyB7gudHkxL2MxmIb+4Jk5 Ug8Q== X-Gm-Message-State: AOJu0Yx3jhEOF1AvyHlQkkOXj6s3M6gwzVkB/15U0jR4+9FQyLYX6ir1 SU6qzV6/Y0XDUy8CsR/6pv1g16zpwa1eWOpnvyzmpM/kCXUx/38aKFHFamZnm92Rs1Y= X-Gm-Gg: AeBDiesEAXb3dGdqpWuzTb99IFqqch5hgDo3/ckolO/f6RemFNuXl2xDUBeAZ/ldoVO NTnwXmE7pS7ks6U9V2GMKNUEp9F23fyTEa+mg5Cerwx/j746GLI2GPB0rKYmXoLeNlquC0LXpvE 0i1dUKOhtLLdYeFxDAkfZgoLQXROJArOqagiDzmg4nJdOITKm0OHPZd8gJbVl6zFRvkagnuJYg8 nM+VJ1FVzWXsM27gP+b/x80W2/UrfO7UB2w37dHz3iZIKMlxCKhkU8u/yHe+MEUWlSOcYZrTjAM aVk4qS0JXAqsZ1iJL7Pdw5wVocDKospKuWXm1/qiA6Hs8lumiDKkW1QcwmoIoRmdRyEotyi3ie5 iYf/Yi3Ng80fLxQGVEUqpYEbeXX5SKBErVWEeWPPJ/uXW6Vecp489cDGZfSp8UBr+is1jXa5Ies /AahWyxtdhoUg9GmIjZ58FN9/hff5PTHE= X-Received: by 2002:a17:90b:56ce:b0:35f:bf23:bd78 with SMTP id 98e67ed59e1d1-3649200cf1amr543676a91.16.1777330922535; Mon, 27 Apr 2026 16:02:02 -0700 (PDT) Received: from localhost ([50.39.133.72]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-36490924f01sm264919a91.1.2026.04.27.16.02.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Apr 2026 16:02:02 -0700 (PDT) Date: Mon, 27 Apr 2026 16:02:01 -0700 From: Zach Brown To: Valerie Aurora Cc: rpdfs-devel@lists.linux.dev Subject: Re: [PATCH 6/8] rpdfs: add file data allocation and lookup routines Message-ID: <20260427230201.GF3280715@localhost.localdomain> References: <20260424140520.3443624-1-val@versity.com> <20260424140520.3443624-7-val@versity.com> Precedence: bulk X-Mailing-List: rpdfs-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260424140520.3443624-7-val@versity.com> On Fri, Apr 24, 2026 at 04:05:18PM +0200, Valerie Aurora wrote: > Add routines to lookup and allocate file data and mapping blocks. > +static int alloc_block_ref(struct rpdfs_fs_info *rfi, struct rpdfs_transaction *txn, > + struct rpdfs_block_ref *ref, struct rpdfs_block_handle **blk_hnd) > +{ > + int ret; > + > + ret = rpdfs_txn_acquire_alloc(rfi, txn, blk_hnd); > + if (ret < 0) > + goto out; > + > + memset((*blk_hnd)->data, 0, RPDFS_BLOCK_SIZE); > + > + ref->bnr = cpu_to_le64((*blk_hnd)->bnr); > + ref->alloc_counter = 0; /* XXX */ > +out: > + rpdfs_prd("ret %d bnr %llu", ret, ref->bnr); > + return ret; > +} This needs to set the place for the new blocks. Maybe something like _PLACE_DATA_MAP and _PLACE_DATA_BLOCK that are after the metadata place definitions. The place offset could be the lblk for the data blocks and some expression of level and lblk for the mapping blocks. > +static int grow_height(struct rpdfs_fs_info *rfi, struct rpdfs_transaction *txn, > + struct inode *inode, struct rpdfs_block_handle *inode_hnd, int height) > +{ > + struct rpdfs_inode_info *ri = RPDFS_I(inode); > + struct rpdfs_block_handle *hnd = NULL; > + struct rpdfs_block_ref *ref; > + struct rpdfs_map_block *iblk; > + struct rpdfs_data_root *dr; > + struct rpdfs_block_ref orig_root; > + u8 level; > + int ret; > + > + dr = &ri->data_root; > + > + rpdfs_prd("dr->height %u goal height %u", dr->height, height); > + > + ret = 0; > + if (height > dr->height) { > + /* start at root and fill in till we get to existing tree */ > + level = height; > + orig_root = dr->ref; /* save current root of tree */ > + ref = &dr->ref; > + > + while (level-- > dr->height) { > + rpdfs_prd("allocing block at level %d", level + 1); > + hnd = NULL; > + ret = alloc_block_ref(rfi, txn, &dr->ref, &hnd); > + if (ret < 0) > + goto out; > + iblk = hnd->data; > + /* growing height will always index old data to 0 */ > + ref = &iblk->refs[0]; > + rpdfs_block_release(rfi, &hnd); > + } > + rpdfs_prd("grafting old height %d tree to new %d height tree", > + dr->height, height); > + /* now put existing tree in mapping block */ > + *ref = orig_root; > + /* and update the height in the data root in the inode */ > + ri->data_root.height = height; > + } > +out: > + return ret; You can lose most of this by always operating on the root instead of juggling local temporary variables. while (ri->data_root.height < height) { alloc(&ref); ... iblk->refs[0] = ri->data_root->ref; ri->data_root->ref = ref; ri->data_root->height++; } > + * XXX: Takes write access on map blocks on write even when it only > + * needs to read them. Redescend with write when we know we have to > + * allocate? Yeah, we don't want to be dirtying parent mapping blocks when streaming writes. It shouldn't have to redescend, though, just release and acquire the parent block. It could save the ref to the parent. - z