PadicoTM

Documentation

« back to PM2 home.
VLink-API.h
Go to the documentation of this file.
1/*
2 * Padico -- a High Performance Parallel and Distributed Computing Environment
3 * Copyright (c) 2002-2026 INRIA and the University of Rennes 1
4 * Alexandre DENIS <Alexandre.Denis@inria.fr>
5 * Christian PEREZ <Christian.Perez@inria.fr>
6 *
7 * The software has been registered at the Agency for the Protection of
8 * Programs (APP) under the number IDDN.FR.001.260013.000.S.P.2002.000.10000.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */
24
30#ifndef VLINK_API_H
31#define VLINK_API_H
32
33#include <Padico/Puk.h>
34#include <Padico/PadicoTM.h>
35#include <Padico/Topology.h>
36#include <Padico/NetSelector.h>
37#include <Padico/SysIO.h>
38
39#include <sys/types.h>
40#include <sys/socket.h>
41#include <sys/stat.h>
42#include <fcntl.h>
43#include <unistd.h>
44#ifdef HAVE_POLL_H
45#include <poll.h>
46#endif
47
48/* *** Opaque types **************************************** */
49
52
53
54/* ********************************************************* */
55/* *** VLink drivers *************************************** */
56
80
90
98
102{
107 void* (*mmap) (void*addr, size_t len, int prot, int flags, padico_vnode_t vnode, off_t off);
108 int (*fcntl) (padico_vnode_t vnode, int cmd, void*arg);
110};
112
113#ifdef _LARGEFILE64_SOURCE
114
118{
119 int (*open) (padico_vnode_t vnode, const char*path, int oflag, mode_t mode);
120 off64_t (*lseek) (padico_vnode_t, off64_t offset, int whence);
121 int (*ftruncate)(padico_vnode_t, off64_t);
122 int (*fstat) (padico_vnode_t vnode, struct stat64*buf);
123 void* (*mmap) (void*addr, size_t len, int prot, int flags, padico_vnode_t vnode, off64_t off);
124 int (*fcntl) (padico_vnode_t vnode, int cmd, void*arg);
125 int (*fsync) (padico_vnode_t vnode);
126};
128
129#endif /* _LARGEFILE64_SOURCE */
130
131
132/* ********************************************************* */
133/* *** Attributes for vobs ********************************* */
134
149
153{
154 volatile int error;
155 unsigned readable : 1;
156 unsigned writable : 1;
157 unsigned opened : 1;
158 unsigned connecting : 1;
159 unsigned end_of_file : 1;
161};
162
191
206
215
216/* This directive builds 'padico_vnode_queue_t' based on 'padico_vnode_t' */
218
227
231{
234 unsigned established: 1;
235 unsigned can_send: 1;
236 unsigned can_recv: 1;
237};
238
251
261
268
269
270/* ********************************************************* */
271/* *** Observers (vobs) ************************************ */
272
276
277
281
290
312
322
323#ifdef POLLIN
324#define VNODE_EVENT_READ POLLIN
325#define VNODE_EVENT_WRITE POLLOUT
326#define VNODE_EVENT_ERROR POLLERR
327#else
328#define VNODE_EVENT_READ 0x01
329#define VNODE_EVENT_WRITE 0x02
330#define VNODE_EVENT_ERROR 0x04
331#endif
332
344
345
346/* ********************************************************* */
347/* *** vnode content *************************************** */
348
349
358
360{
361 unsigned hfd : 1;
362 unsigned socket : 1;
363 unsigned binding : 1;
364 unsigned remote : 1;
365 unsigned listener : 1;
366 unsigned rbox : 1;
367 unsigned wbox : 1;
368 unsigned pivot : 1;
369 unsigned connect : 1;
370};
371
379
383{
385#ifdef DEBUG
386 volatile int lock_count;
387 volatile marcel_t lock_owner;
388#endif
389 void*cookie;
391 /* ** content fields */
393 volatile struct vobs_attr_status_s status;
394 struct vobs_attr_rbox_s rbox; /* generic I/O */
395 struct vobs_attr_wbox_s wbox; /* generic I/O */
396 struct vobs_attr_observer_s observer; /* generic I/O */
397 struct vobs_attr_pivot_s pivot; /* generic I/O */
398 struct vobs_attr_socket_s socket; /* generic vsock */
399 struct vobs_attr_remote_s remote; /* generic vsock */
400 struct vobs_attr_binding_s binding; /* generic vsock */
401 struct vobs_attr_listener_s listener; /* generic vsock */
402 struct vnode_hfd_s hfd; /* hfd toolbox */
403};
404
405/* *** Locking ********************************************* */
406
407static inline void vnode_lock(padico_vnode_t vnode)
408{
410#ifdef DEBUG
411 assert(vnode->lock_count == 0);
412 vnode->lock_count++;
413 vnode->lock_owner = marcel_self();
414#endif
415}
417{
418#ifdef DEBUG
419 assert(vnode->lock_owner == marcel_self());
420 vnode->lock_owner = (marcel_t)NULL;
421 vnode->lock_count--;
422 assert(vnode->lock_count == 0);
423#endif
425}
427{
429#ifdef DEBUG
430 if(success)
431 {
432 assert(vnode->lock_count == 0);
433 vnode->lock_count++;
434 vnode->lock_owner = marcel_self();
435 }
436#endif
437 return success;
438}
440{
441#ifdef DEBUG
442 vnode->lock_count--;
443 vnode->lock_owner = (marcel_t)NULL;
444#endif
446#ifdef DEBUG
447 vnode->lock_owner = marcel_self();
448 vnode->lock_count++;
449#endif
450}
451
452/* *** vobs secondary ************************************** */
453
459
461{
462 marcel_mutex_lock(&obs->lock);
463}
465{
467}
468
469/* *** vobs primary **************************************** */
470
476{
477#ifdef DEBUG
478 assert(vnode->lock_count > 0);
479 assert(vnode->lock_owner == marcel_self());
480#endif
481
482 /* notifiers (from primary observer) */
484 {
485 /* since the invocation runs unlocked, we cannot invoke directly
486 * vnode->observer.notifier.
487 * Take a copy of the notifier and invoke the copy.
488 */
489 struct vobs_notify_s notify = vnode->observer.notifier;
491 (*notify.func)(vnode, attr, notify.key);
493 }
494 /* secondary observers */
497 {
498 assert(s->obs != NULL);
499 marcel_mutex_lock(&s->obs->lock);
500 marcel_cond_signal(&s->obs->waiting);
501 marcel_mutex_unlock(&s->obs->lock);
502 }
503 /* primary observer */
505}
506static inline void vobs_wait(padico_vnode_t vnode)
507{
508#ifdef DEBUG
509 assert(vnode->lock_count > 0);
510 assert(vnode->lock_owner == marcel_self());
511#endif
513}
514
515static inline void vobs_subscribe(padico_vnode_t vnode, vobs_notifier_func_t callback, void*key)
516{
518 vnode->observer.notifier.func = callback;
520}
521
523{
525}
526
528{
530 vnode->observer.commit = commit;
531}
532
534{
535 if(vnode->observer.commit != NULL)
536 {
538 }
539}
540
541/* *** Generic vnode API *********************************** */
542
545ssize_t padico_vnode_write_post (padico_vnode_t, const void*, size_t);
548
550
551/* *** VSock API ******************************************* */
552
553void padico_vsock_init(padico_vnode_t vnode, int domain, int type, int protocol);
554int padico_vsock_create(padico_vnode_t vnode, int domain, int type, int protocol);
559ssize_t padico_vsock_sendto(padico_vnode_t vnode, const void*buf, size_t len,
560 int flags, const struct sockaddr *to, int tolen);
562 int flags, struct sockaddr *from, int *fromlen);
564
565/* *** Error management ************************************ */
566
567static inline int vlink_is_transient_error(int err)
568{
569 return ( (err) == EINPROGRESS ||
570 (err) == EAGAIN ||
571 (err) == EINTR ||
572 (err) == EWOULDBLOCK );
573}
574static inline void vnode_set_error(padico_vnode_t vnode, int err)
575{
577}
579{
580 return vnode->status.error;
581}
583{
585}
587{
589 return (err != 0 && !(vlink_is_transient_error(err)));
590}
592{
594 return (err != 0 && (vlink_is_transient_error(err)));
595}
596
597#endif /* VLINK_API_H */
static pthread_cond_t cond
assert(slab_size > 0)
const const struct ns_rule_bucket_s * key
PUK_IFACE_TYPE(ProxyFactory, struct padico_proxyfactory_s)
return NULL
Definition Shm.h:88
uintptr_t s
Definition Shm.h:88
static const char * path
static int done
Definition console-mod.c:49
enum @14::@15::@16 mode
static int size
Definition datacheck.c:34
padico_task_notifier_t notify
Definition PadicoTM.h:147
void * arg
Definition PadicoTM.h:167
#define padico_io_t
for backwards compatibility with legacy codes
Definition SysIO.h:53
struct topo_node_s * padico_topo_node_t
Definition Topology.h:76
const int timeout
Definition psp-mx.c:119
Driver for interface: 'VFile'.
Definition VLink-API.h:102
off_t(* lseek)(padico_vnode_t, off_t offset, int whence)
Definition VLink-API.h:104
int(* fstat)(padico_vnode_t vnode, struct stat *buf)
Definition VLink-API.h:106
int(* fcntl)(padico_vnode_t vnode, int cmd, void *arg)
Definition VLink-API.h:108
int(* ftruncate)(padico_vnode_t, off_t)
Definition VLink-API.h:105
int(* open)(padico_vnode_t vnode, const char *path, int oflag, mode_t mode)
Definition VLink-API.h:103
int(* fsync)(padico_vnode_t vnode)
Definition VLink-API.h:109
A single vnode R/W observer.
Definition VLink-API.h:316
short oevents
original events form pollfd struct
Definition VLink-API.h:318
short revent
result value
Definition VLink-API.h:320
short event
event beeing observed
Definition VLink-API.h:319
padico_vnode_t vnode
Definition VLink-API.h:317
virtual node descriptor, common to any file type
Definition VLink-API.h:383
struct vobs_attr_binding_s binding
Definition VLink-API.h:400
struct vobs_attr_wbox_s wbox
Definition VLink-API.h:395
struct vnode_assembly_stuff_s assembly_stuff
Definition VLink-API.h:390
struct vobs_attr_socket_s socket
Definition VLink-API.h:398
struct vobs_attr_remote_s remote
Definition VLink-API.h:399
struct padico_vnode_content_t content
Definition VLink-API.h:392
struct vnode_hfd_s hfd
Definition VLink-API.h:402
struct vobs_attr_observer_s observer
Definition VLink-API.h:396
pthread_mutex_t * lock_ptr
lock from the instance
Definition VLink-API.h:384
struct vobs_attr_pivot_s pivot
Definition VLink-API.h:397
struct vobs_attr_rbox_s rbox
Definition VLink-API.h:394
struct vobs_attr_listener_s listener
Definition VLink-API.h:401
volatile struct vobs_attr_status_s status
Definition VLink-API.h:393
void * cookie
data used by the user of this vnode
Definition VLink-API.h:389
Driver for interface: 'VPipe'.
Definition VLink-API.h:94
int(* pipe)(padico_vnode_t vnodes[2])
Definition VLink-API.h:95
void * specific
component-specific state
Definition VLink-API.h:376
const struct padico_vlink_driver_s * vlink_driver
Definition VLink-API.h:377
puk_context_t context
the vnode's context in the assembly (may be NULL)
Definition VLink-API.h:375
puk_instance_t instance
the component instance the vnode is status (i.e.
Definition VLink-API.h:374
virtual node descriptor specialized for real (kernel) file descriptors.
Definition VLink-API.h:353
int fd
associated file descriptor
Definition VLink-API.h:354
padico_sysio_t io_write
Definition VLink-API.h:356
padico_sysio_t io_read
Definition VLink-API.h:355
a (local) binding for a socket
Definition VLink-API.h:210
int autobind
auto-bind request: padico_vsock_bind() will allocate a new address
Definition VLink-API.h:213
socklen_t primary_len
Definition VLink-API.h:212
struct sockaddr * primary
Definition VLink-API.h:211
a listener for a socket
Definition VLink-API.h:222
int backlog_size
max size of the backlog queue
Definition VLink-API.h:224
const struct padico_vaddr_s * src_addr
Definition VLink-API.h:225
padico_vnode_queue_t backlog
incoming connections queue.
Definition VLink-API.h:223
vobs_notifier_func_t func
function called upon event (NULL if none)
Definition VLink-API.h:307
void * key
arg given to above function
Definition VLink-API.h:308
An observer record inside a vnode.
Definition VLink-API.h:302
struct vobs_secondary_ref_vect_s secondary
secondary observers who are watching us
Definition VLink-API.h:310
vobs_commit_func_t commit
'commit' observer: invoked to signal changes in direct-access attributes
Definition VLink-API.h:303
struct vobs_attr_observer_s::vobs_notify_s notifier
handler for notifying changes in observed attributes (called upon event)
pthread_cond_t wait_event
cond signaled upon io event.
Definition VLink-API.h:304
a pivot request
Definition VLink-API.h:265
padico_vnode_t new_vnode
Definition VLink-API.h:266
an incoming (read) mailbox
Definition VLink-API.h:242
struct sockaddr * from
Definition VLink-API.h:247
int cant_interrupt_read
lock this flag not to interrupt a read operation
Definition VLink-API.h:246
ssize_t read_posted
Definition VLink-API.h:243
pthread_t tid
Definition VLink-API.h:249
the peer of a connected socket
Definition VLink-API.h:231
socklen_t remote_addrlen
Definition VLink-API.h:233
unsigned established
Definition VLink-API.h:234
struct sockaddr * remote_addr
Definition VLink-API.h:232
status description specialized for virtual sockets (vsocks).
Definition VLink-API.h:195
int so_protocol
specific protocol
Definition VLink-API.h:204
unsigned capabilities
socket capabilities exposed by the driver (bitmask) [read-only for the user]
Definition VLink-API.h:196
unsigned so_options
socket options (bitmask)
Definition VLink-API.h:197
int so_type
protocol type (SOCK_STREAM, SOCK_DGRAM,...)
Definition VLink-API.h:203
int so_family
network family (AF_INET,...)
Definition VLink-API.h:202
status description for generic I/O
Definition VLink-API.h:153
volatile int error
error state
Definition VLink-API.h:154
unsigned end_of_file
we reached end-of-file
Definition VLink-API.h:159
unsigned writable
immediate 'write' will not block
Definition VLink-API.h:156
unsigned readable
immediate 'read' will not block
Definition VLink-API.h:155
unsigned connecting
we are in the connection phase
Definition VLink-API.h:158
uint8_t pending_op
asynchronous operation in progress- vnode cannot be closed
Definition VLink-API.h:160
unsigned opened
this vnode is currently opened
Definition VLink-API.h:157
an outgoing (write) mailbox
Definition VLink-API.h:255
ssize_t write_done
Definition VLink-API.h:257
ssize_t write_posted
Definition VLink-API.h:256
void * write_buffer
Definition VLink-API.h:258
A reference to a secondary observer watching us (us, the vnode)
Definition VLink-API.h:285
int index
our rank in the above observer
Definition VLink-API.h:287
struct vobs_secondary_s * obs
the secondary observer
Definition VLink-API.h:286
A secondary vnode R/W observer, for a group of vnodes.
Definition VLink-API.h:337
pthread_cond_t waiting
Definition VLink-API.h:341
struct padico_vnode_observer_s * observers
the primary observers we are watching
Definition VLink-API.h:338
pthread_mutex_t lock
Definition VLink-API.h:340
int n_obs
number of primary observers
Definition VLink-API.h:339
static int port
Definition vrp-test.c:15