From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (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 899AA429811 for ; Thu, 26 Feb 2026 20:39:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772138355; cv=none; b=j0MuSqZos5JuG+N3VTFF/je5W/CaJgANOKKj2UQ+JisxywE2rBgboHz+P9TkGkplR+epheEV+jgI8FodDA28UNOJkD/qxG7lLZoz0IXPafNu9m0uBgpLiAEw7annLi19sD5wdHP0RwJktGMQd5AG7JbrAOF77JRYGKom4m2P3/8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772138355; c=relaxed/simple; bh=Y3FjzpkY0OyVPCxiOz+D9v5gftBDmxqK1JoDT8kYAqw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=lzW5CitGOLodKjF5JzGePO6QvTdQKi+G4X087hyEoTVX0IyHBY/GqHWD9OHrc0DWn2ZQym4mhGMCm2ng1TRAEJoqCE+Z08su/HiLzurhv0zD+V2R3kpKQsycpdCoMcOA5g/U1jgFGXfHpDn2XgU/bmtMoZB/yqQ+DocZZe9iPhA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=permerror header.from=versity.com; spf=pass smtp.mailfrom=versity.com; dkim=pass (2048-bit key) header.d=versity.com header.i=@versity.com header.b=JYRw7mN0; arc=none smtp.client-ip=209.85.208.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=permerror header.from=versity.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=versity.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=versity.com header.i=@versity.com header.b="JYRw7mN0" Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-65f71ed7c6cso2415259a12.0 for ; Thu, 26 Feb 2026 12:39:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=versity.com; s=google; t=1772138352; x=1772743152; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=+BujJi/aZzIvkDqRzQ3E5YQd8U36pCsWWMspdd2zyUA=; b=JYRw7mN0Mr3JCpobmMmVYlLJE/IVrUb5/fFExAljgAXZhJB3yB8BUWvQ5LW06ulQmy pCYNtAI1NcpSAIqtPe3RFVdJIM7GLMQfgEg0kc0U7iRR2iMolJh8/amD/Sa80315dwON ++WzYjQIG0I6vnXD7p4DgBU49z6ZxO4c31EfmX0b+jeNKF/3/L+X6myK0GoCB/5hvNJj 0lgVJIfGNxyu5pTWAC6napvF6H8xaElwkthhLC0CBe3YTj/bmml5NdVzZoCYfMJEErHq c1HnLnrfNbZNhae5N4noR8b1/ZH9E9lfdH8DjbYeBXNiYdRXb6Jm8B/qRgMWO9CYgm9D JOoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772138352; x=1772743152; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+BujJi/aZzIvkDqRzQ3E5YQd8U36pCsWWMspdd2zyUA=; b=BFGqP74INQjdabiEhRd5a76FsgAXqqxLY7jaqgf0b6bRZqk//uBIQbDiJ9+oBPOWfc 3g/9luYnjAFyPp2r2/rVo0B1Hk9dc0DXHLgoWvyfYD0zANj+yxSTSfsO7dGQgsoya+Ew f/9p3f46SkNnKW0gSYPN9/e/8RcAkUO3ofJPc1ZZ0kPdWhBQ4nRphJFeTHr8rSag6wtb dj1oZdM8W44beGLFnguMzpmMGB9BGjWKRptVixJrnM6WmOnddFj+d4X1on4XOIFeYnWK LtUC3Tgpwu2bOARiGVq96Rosl+gV7jpy3hr9LCUSdI9n4G4CPTDQIN5FujRN3qKFgJyX tlEg== X-Gm-Message-State: AOJu0Yx6QCp8A0jNcwUoqgojFb05U6to0Gz8sZfQvMj7sUEVgTb91Tq/ NQTthRhd0PIxigzHtWwXEtdb0DVjNKQ+6C/x3ZAlii+ZZpDRJMvj59ibq4tH6/oYMIOqWRbjlPn BPCd5 X-Gm-Gg: ATEYQzxs5t4i9+BzX/KbLKsAeP25RHzNTZ00qguGZsxjZGtcEq5VwQyfGgdTCZ2dmoA pHt4W9aIpCga+F+A6S3c5T3v1AY02wTl/3NbioZOIMb98oC44HOxK+MwcoFespxQ6+Nvf7bGR77 Tb5ZRcSICyUAK2Yn2IDNXSU+VC9dDz4U8bFbb+W2wkg1dQSJLoVTUqbNStpXs9eLzvBOtLtCzUc JZLJARiZfpVVT0fMtEiGWu5oLJh21MzgtJ+glS2q8eBIA2wqmvUK0qSxXuu7sk6FfDc5WehM5eA aDtUDK0o7apN+fo9UDWqR3c1uMO7cocAu7Hr6pJwuogCkjIvUNu/NkGYYJEMg3VcGoqw59S/fUR dFsbN4s6nS/r7X/KR2tVJ3QwnB/Llql2QUZ2NSkHcr7XBzXZ2gmF8KcWz2RiZj5gyA+a2fML/ec 0ez6J7z1OJgOvSj15CM1CSP2FmpGAMJ5PFCK84b6hePSymBbEo+FfLAD/zLiTdoyRA0MA= X-Received: by 2002:a05:6402:5191:b0:659:4554:2dbd with SMTP id 4fb4d7f45d1cf-65fdd6bdb2fmr445231a12.7.1772138350949; Thu, 26 Feb 2026 12:39:10 -0800 (PST) Received: from localhost.localdomain (46-117-212-87.ftth.glasoperator.nl. [87.212.117.46]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-65fabf6d0fbsm829425a12.20.2026.02.26.12.39.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Feb 2026 12:39:10 -0800 (PST) From: Valerie Aurora To: rpdfs-devel@lists.linux.dev Cc: Valerie Aurora Subject: [PATCH] Add rpdfs_unlink() and rpdfs_rmdir() Date: Thu, 26 Feb 2026 21:38:58 +0100 Message-ID: <20260226203858.23117-1-val@versity.com> X-Mailer: git-send-email 2.49.0 Precedence: bulk X-Mailing-List: rpdfs-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Copied from rpdfs_rename() and the extra bits removed. Signed-off-by: Valerie Aurora --- fs/rpdfs/dir.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/fs/rpdfs/dir.c b/fs/rpdfs/dir.c index 115f879d8fb1..473f7a7e6c13 100644 --- a/fs/rpdfs/dir.c +++ b/fs/rpdfs/dir.c @@ -491,6 +491,74 @@ static struct dentry *rpdfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, return ERR_PTR(create_and_instantiate_new(idmap, dir, dentry, S_IFDIR | mode)); } +static int rpdfs_unlink(struct inode *dir, struct dentry *dentry) +{ + struct rpdfs_fs_info *rfi = RPDFS_INODE_FS(dir); + struct inode *inode = d_inode(dentry); + struct key_dent *kd = NULL; + DECLARE_RPDFS_TXN(txn); + int ret; + + kd = alloc_key_dent(dentry, inode); + if (!kd) { + ret = -ENOMEM; + goto out; + } + + /* prepare all the blocks for the txn */ + do { + ret = rpdfs_inode_txn_prepare(rfi, &txn, dir, RBAF_WRITE) ?: + rpdfs_inode_txn_prepare(rfi, &txn, inode, RBAF_WRITE) ?: + prepare_remove_entry(rfi, &txn, dir, kd); + } while (rpdfs_txn_retry(rfi, &txn, &ret)); + if (ret < 0) + goto out; + + /* + * The VFS did a bunch of checks before calling this function, + * but some other node could have made changes between then and + * now. The prepare functions only succeed if the inodes have + * not been freed or reused, and if the directory entry to be + * removed is still there. The remaining check is if the target + * dir of an rmdir is still empty. + */ + + if (S_ISDIR(inode->i_mode)) { + if (!simple_empty(dentry)) { + ret = -ENOTEMPTY; + goto out; + } + drop_nlink(dir); + clear_nlink(inode); + } else { + drop_nlink(inode); + } + inode_set_ctime_current(inode); + + /* apply changes to block structures */ + apply_remove_entry(rfi, &txn, dir, kd); + + /* update dir size and time */ + i_size_write(dir, i_size_read(dir) - dentry->d_name.len); + inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); + + /* update block storage of vfs inodes */ + rpdfs_inode_txn_update(rfi, &txn, dir); + rpdfs_inode_txn_update(rfi, &txn, inode); + + ret = 0; +out: + rpdfs_txn_reset(rfi, &txn); + kfree(kd); + + return ret; +} + +static int rpdfs_rmdir(struct inode *dir, struct dentry *dentry) +{ + return rpdfs_unlink(dir, dentry); +} + /* * The vfs has verified the cached directories. Our inode refresh will * fail if the inodes have been reused, so we don't have to test if @@ -532,7 +600,7 @@ static int rpdfs_rename(struct mnt_idmap *idmap, struct inode *old_dir, struct d goto out; } - /* prepare all the blocks for in the txn */ + /* prepare all the blocks for the txn */ do { ret = rpdfs_inode_txn_prepare(rfi, &txn, old_dir, RBAF_WRITE) ?: rpdfs_inode_txn_prepare(rfi, &txn, old_inode, RBAF_WRITE) ?: @@ -551,6 +619,11 @@ static int rpdfs_rename(struct mnt_idmap *idmap, struct inode *old_dir, struct d if (ret < 0) goto out; + /* + * TODO: walk ancestors, and if there is a directory to be + * deleted, check if it is empty. + */ + /* apply changes to block structures */ apply_remove_entry(rfi, &txn, old_dir, old_kd); if (new_inode) @@ -680,6 +753,8 @@ const struct inode_operations rpdfs_dir_iops = { .lookup = rpdfs_lookup, .mkdir = rpdfs_mkdir, .rename = rpdfs_rename, + .unlink = rpdfs_unlink, + .rmdir = rpdfs_rmdir, }; const struct file_operations rpdfs_dir_fops = { -- 2.49.0