summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-10-15 14:48:21 -0400
committerIan Moffett <ian@osmora.org>2025-10-15 14:48:21 -0400
commitf39d4994c80225986fb6b27ef2ecef9268540b69 (patch)
tree22fffdcaa7f704f77ec77a71cdabd0d9c5e29be5
parent4343f79fb78d9c3e4b2c7e09147cc499562593d2 (diff)
kern: vfs: Add reclaim callback to vnode
The reclaim callback simply reclaims any filesystem specific resources used with vnodes back to the operating system. Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r--src/sys/include/os/vnode.h12
-rw-r--r--src/sys/os/vfs_subr.c21
2 files changed, 33 insertions, 0 deletions
diff --git a/src/sys/include/os/vnode.h b/src/sys/include/os/vnode.h
index 9054a55..1bef1e2 100644
--- a/src/sys/include/os/vnode.h
+++ b/src/sys/include/os/vnode.h
@@ -88,6 +88,7 @@ struct vop_rw_data {
*/
struct vop {
int(*lookup)(struct vop_lookup_args *args);
+ int(*reclaim)(struct vnode *vp, int flags);
ssize_t(*write)(struct vop_rw_data *data);
ssize_t(*read)(struct vop_rw_data *data);
};
@@ -164,4 +165,15 @@ ssize_t vop_write(struct vnode *vp, char *data, off_t off, size_t len);
*/
ssize_t vop_read(struct vnode *vp, char *data, off_t off, size_t len);
+/*
+ * Reclaim the resources tied to a specific vnode
+ *
+ * @vp: Vnode to reclaim
+ * @flags: Optional flags
+ *
+ * Returns zero on success, otherwise a less than zero value
+ * on failure.
+ */
+int vop_reclaim(struct vnode *vp, int flags);
+
#endif /* !_OS_VNODE_H_ */
diff --git a/src/sys/os/vfs_subr.c b/src/sys/os/vfs_subr.c
index a06b64f..6cb7767 100644
--- a/src/sys/os/vfs_subr.c
+++ b/src/sys/os/vfs_subr.c
@@ -203,3 +203,24 @@ vop_read(struct vnode *vp, char *data, off_t off, size_t len)
rwdata.off = off;
return vops->read(&rwdata);
}
+
+int
+vop_reclaim(struct vnode *vp, int flags)
+{
+ struct vop *vops;
+
+ if (vp == NULL) {
+ return -EINVAL;
+ }
+
+ /* Grab the virtual operations */
+ if ((vops = vp->vops) == NULL) {
+ return -EIO;
+ }
+
+ if (vops->reclaim == NULL) {
+ return -ENOTSUP;
+ }
+
+ return vops->reclaim(vp, flags);
+}