The next commit will make mode_t 32-bits, ino_t 64-bits, nlink_t 32-bits, and off_t 64-bits. However, in the protocol there is no room for that. When analyzing the usage of these data types we can see that of mode_t we currently use 15 bits and that future flags (if copied from NetBSD) are only of importance to VFS and not to the actual file system on disk. Therefore we can get away with keeping the protocol version of mode_t (pmode_t) 16 bits. At this point it is unlikely that MINIX will support file systems that can hold more than 2^32 files. Keeping the protocol version of ino_t (pino_t) 32-bits and exposing it as 64-bits to the rest of the system is fine. uid_t and gid_t are already 32-bits, but in behind the scenes they're 16-bits. This is sufficient since we don't support uid/gids larger than 2^16-1. off_t will become 64-bits, but the protocol had room reserved for that since it was revised years ago. So to make the difference clear between what the protocol supports and what is exposed to the system, we define protocol version of these data types. Change-Id: Ifb883aafb222142e69d6dcc3049a47170b78b3ee
104 lines
2.7 KiB
C
104 lines
2.7 KiB
C
/*
|
|
* Created (MFS based):
|
|
* June 2011 (Evgeniy Ivanov)
|
|
*/
|
|
|
|
#include "fs.h"
|
|
#include <string.h>
|
|
#include <assert.h>
|
|
#include <minix/vfsif.h>
|
|
|
|
#include "puffs.h"
|
|
#include "puffs_priv.h"
|
|
|
|
|
|
void release_node(struct puffs_usermount *pu, struct puffs_node *pn)
|
|
{
|
|
assert(pn->pn_count == 0);
|
|
|
|
/* Required if puffs_node_reclaim() decides to leave node in the list */
|
|
pn->pn_mountpoint = FALSE;
|
|
|
|
if (pu->pu_ops.puffs_node_reclaim) {
|
|
if (global_pu->pu_ops.puffs_node_reclaim(global_pu, pn) != 0)
|
|
lpuffs_debug("Warning: reclaim failed\n");
|
|
} else {
|
|
puffs_pn_put(pn);
|
|
}
|
|
}
|
|
|
|
|
|
/*===========================================================================*
|
|
* fs_putnode *
|
|
*===========================================================================*/
|
|
int fs_putnode(void)
|
|
{
|
|
/* Find the pnode specified by the request message and decrease its counter.
|
|
* Release unused pnode.
|
|
*/
|
|
struct puffs_node *pn;
|
|
int count = fs_m_in.REQ_COUNT;
|
|
pino_t inum = fs_m_in.REQ_INODE_NR;
|
|
|
|
if ((pn = puffs_pn_nodewalk(global_pu, 0, &inum)) == NULL) {
|
|
/* XXX Probably removed from the list, see puffs_pn_remove() */
|
|
struct puffs_node *pn_cur, *pn_next;
|
|
pn_cur = LIST_FIRST(&global_pu->pu_pnode_removed_lst);
|
|
while (pn_cur) {
|
|
pn_next = LIST_NEXT(pn_cur, pn_entries);
|
|
if (pn_cur->pn_va.va_fileid == inum) {
|
|
pn = pn_cur;
|
|
break;
|
|
}
|
|
pn_cur = pn_next;
|
|
}
|
|
}
|
|
|
|
if (pn == NULL) {
|
|
lpuffs_debug("%s:%d putnode: pnode #%ld dev: %d not found\n", __FILE__,
|
|
__LINE__, inum, fs_dev);
|
|
panic("fs_putnode failed");
|
|
}
|
|
|
|
if (count <= 0) {
|
|
lpuffs_debug("%s:%d putnode: bad value for count: %d\n", __FILE__,
|
|
__LINE__, count);
|
|
panic("fs_putnode failed");
|
|
} else if (pn->pn_count == 0) {
|
|
/* FUSE fs might store in the list pnodes, which we hasn't
|
|
* open, this means we got put request for file,
|
|
* which wasn't opened by VFS.
|
|
*/
|
|
lpuffs_debug("%s:%d putnode: pn_count already zero\n", __FILE__,
|
|
__LINE__);
|
|
panic("fs_putnode failed");
|
|
} else if (count > pn->pn_count) {
|
|
struct puffs_node *pn_cur, *pn_next;
|
|
struct puffs_usermount *pu = global_pu;
|
|
ino_t ino = pn->pn_va.va_fileid;
|
|
|
|
pn_cur = LIST_FIRST(&pu->pu_pnodelst);
|
|
lpuffs_debug("inum count path polen hash\n");
|
|
while (pn_cur) {
|
|
pn_next = LIST_NEXT(pn_cur, pn_entries);
|
|
if (pn_cur->pn_va.va_fileid == ino) {
|
|
lpuffs_debug("%ld: %d %s %u %u\n", ino, pn_cur->pn_count,
|
|
pn_cur->pn_po.po_path,
|
|
pn_cur->pn_po.po_len,
|
|
pn_cur->pn_po.po_hash);
|
|
}
|
|
pn_cur = pn_next;
|
|
}
|
|
lpuffs_debug("%s:%d putnode: count too high: %d > %d\n", __FILE__,
|
|
__LINE__, count, pn->pn_count);
|
|
panic("fs_putnode failed");
|
|
}
|
|
|
|
pn->pn_count -= count;
|
|
|
|
if (pn->pn_count == 0)
|
|
release_node(global_pu, pn);
|
|
|
|
return(OK);
|
|
}
|