3 * June 2011 (Evgeniy Ivanov)
9 #include <minix/vfsif.h>
12 #include "puffs_priv.h"
15 void release_node(struct puffs_usermount
*pu
, struct puffs_node
*pn
)
17 assert(pn
->pn_count
== 0);
19 /* Required if puffs_node_reclaim() decides to leave node in the list */
20 pn
->pn_mountpoint
= FALSE
;
22 if (pu
->pu_ops
.puffs_node_reclaim
) {
23 if (global_pu
->pu_ops
.puffs_node_reclaim(global_pu
, pn
) != 0)
24 lpuffs_debug("Warning: reclaim failed\n");
31 /*===========================================================================*
33 *===========================================================================*/
36 /* Find the pnode specified by the request message and decrease its counter.
37 * Release unused pnode.
39 struct puffs_node
*pn
;
40 int count
= fs_m_in
.m_vfs_fs_putnode
.count
;
41 ino_t inum
= fs_m_in
.m_vfs_fs_putnode
.inode
;
43 if ((pn
= puffs_pn_nodewalk(global_pu
, 0, &inum
)) == NULL
) {
44 /* XXX Probably removed from the list, see puffs_pn_remove() */
45 struct puffs_node
*pn_cur
, *pn_next
;
46 pn_cur
= LIST_FIRST(&global_pu
->pu_pnode_removed_lst
);
48 pn_next
= LIST_NEXT(pn_cur
, pn_entries
);
49 if (pn_cur
->pn_va
.va_fileid
== inum
) {
58 lpuffs_debug("%s:%d putnode: pnode #%ld dev: %d not found\n", __FILE__
,
59 __LINE__
, inum
, fs_dev
);
60 panic("fs_putnode failed");
64 lpuffs_debug("%s:%d putnode: bad value for count: %d\n", __FILE__
,
66 panic("fs_putnode failed");
67 } else if (pn
->pn_count
== 0) {
68 /* FUSE fs might store in the list pnodes, which we hasn't
69 * open, this means we got put request for file,
70 * which wasn't opened by VFS.
72 lpuffs_debug("%s:%d putnode: pn_count already zero\n", __FILE__
,
74 panic("fs_putnode failed");
75 } else if (count
> pn
->pn_count
) {
76 struct puffs_node
*pn_cur
, *pn_next
;
77 struct puffs_usermount
*pu
= global_pu
;
78 ino_t ino
= pn
->pn_va
.va_fileid
;
80 pn_cur
= LIST_FIRST(&pu
->pu_pnodelst
);
81 lpuffs_debug("inum count path polen hash\n");
83 pn_next
= LIST_NEXT(pn_cur
, pn_entries
);
84 if (pn_cur
->pn_va
.va_fileid
== ino
) {
85 lpuffs_debug("%ld: %d %s %u %u\n", ino
, pn_cur
->pn_count
,
86 pn_cur
->pn_po
.po_path
,
88 pn_cur
->pn_po
.po_hash
);
92 lpuffs_debug("%s:%d putnode: count too high: %d > %d\n", __FILE__
,
93 __LINE__
, count
, pn
->pn_count
);
94 panic("fs_putnode failed");
97 pn
->pn_count
-= count
;
99 if (pn
->pn_count
== 0)
100 release_node(global_pu
, pn
);