From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: Date: Mon, 1 Feb 2016 19:54:58 -0200 Message-ID: From: Tiago Natel To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=e89a8f647adda6953b052abc6f55 Subject: [9fans] Fwd: lib9p: Add clunk callback to Srv struct Topicbox-Message-UUID: 80e58fbe-ead9-11e9-9d60-3106f5b1d025 --e89a8f647adda6953b052abc6f55 Content-Type: text/plain; charset=UTF-8 Someone here can help me? ---------- Forwarded message ---------- From: Tiago Natel Date: 2016-02-01 19:17 GMT-02:00 Subject: lib9p: Add clunk callback to Srv struct To: 9front@9front.org Hello folks, Is there a reason why lib9p doesn't have a clunk function pointer in Srv struct? I have a file server project using Srv and I want to know when no one client have a specific file opened. One way that I was able to get this working was forking 9front and adding a clunk callback to Srv structure. See the commit below: https://bitbucket.org/tiago4orion/plan9front/commits/5e1141f0a4aa98310cb0e2382c5c78c60fe73b4f My project usage of the clunk routine is here: https://bitbucket.org/tiago4orion/dchan/src/60dc3e45eb28c8a8289c177680120ef7f44e0925/fs.c?fileviewer=file-view-default#fs.c-680 This makes sense? Or is there better ways to achieve this? And if that makes sense, it can go upstream? Thanks. --e89a8f647adda6953b052abc6f55 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Someone here can help me?

---------- Forwarded message ----------
From: Tiago Natel <tiago.natel@neoway.com.br>
Date: 2016-02-01= 19:17 GMT-02:00
Subject: lib9p: Add clunk callback to Srv struct
To:= 9front@9front.org


Hello folks,

Is there a reason why lib9p do= esn't have a clunk function pointer in Srv struct?

=
I have a file server project using Srv and I want to know when no one = client have a specific file opened.=C2=A0

One way = that I was able to get this working was forking 9front and adding a clunk c= allback to Srv structure. See the commit below:

https://bitbucket.org/tiago4= orion/plan9front/commits/5e1141f0a4aa98310cb0e2382c5c78c60fe73b4f

My project usage of the clunk routine is here:

This makes sense? Or is there better ways to a= chieve this?
And if that makes sense, it can go upstream?

Thanks.


--e89a8f647adda6953b052abc6f55-- From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: Date: Mon, 1 Feb 2016 23:03:23 +0100 From: cinap_lenrek@felloff.net To: 9fans@9fans.net In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] Fwd: lib9p: Add clunk callback to Srv struct Topicbox-Message-UUID: 80e9fafe-ead9-11e9-9d60-3106f5b1d025 > Is there a reason why lib9p doesn't have a clunk function pointer in Srv struct? what about Srv.destroyfid()? Destroyfid When a Fid's reference count drops to zero (i.e., it has been clunked and there are no outstanding requests referring to it), destroyfid is called to allow the program to dispose of the fid->aux pointer. -- cinap From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: To: 9fans@9fans.net Date: Mon, 1 Feb 2016 14:42:26 -0800 From: Skip Tavakkolian <9nut@9netics.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] Fwd: lib9p: Add clunk callback to Srv struct Topicbox-Message-UUID: 80f62bf8-ead9-11e9-9d60-3106f5b1d025 > I have a file server project using Srv and I want to know when no one > client have a specific file opened. i believe since you're using alloctree and passing in the destroy function, you don't need it. From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: Date: Tue, 2 Feb 2016 16:17:26 -0200 Message-ID: From: Tiago Natel To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=001a114432ae7bd651052acd834f Subject: Re: [9fans] Fwd: lib9p: Add clunk callback to Srv struct Topicbox-Message-UUID: 81e0192a-ead9-11e9-9d60-3106f5b1d025 --001a114432ae7bd651052acd834f Content-Type: text/plain; charset=UTF-8 2016-02-01 20:03 GMT-02:00 : > > Is there a reason why lib9p doesn't have a clunk function pointer in Srv > struct? > > what about Srv.destroyfid()? > > Destroyfid > When a Fid's reference count drops to zero (i.e., it > has been clunked and there are no outstanding requests > referring to it), destroyfid is called to allow the > program to dispose of the fid->aux pointer. > > Thanks for your help! I'd tried using destroyfid to achieve what I need but failed. I tried today again implement with destroyfid but realized that it will not fully support what I need. I'm using a file server for exchange data between 9P clients. When a new file is created, I create a plan9 channel and two threads (one for handle reads and other for writes), a write(2) to the file is translated into a sendp and a read(2) is translated into a recvp on the channel. The channel could be buffered or not, and then I want to maintain data allocated (aux related data) anyway, because the file server is a queueing system when channel have a buffer bigger than zero. Apart from that, I want to know how many clients have each file opened to update my stats file. It's possible in any way without a clunk callback? I'm trying to replace a rabbitmq server with this system, but I have a requirement for some way of monitoring of queues size, performance of channels, number of clients connected to each channel (file on dchan), etc, I need this kind of information for make a comparison with the current queue system... Thanks! -- > cinap > > --001a114432ae7bd651052acd834f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


2016-02-01 20:03 GMT-02:00 <cinap_lenrek@felloff.net>:
> Is there a r= eason why lib9p doesn't have a clunk function pointer in Srv struct?
what about Srv.destroyfid()?

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Destroyfid
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0When a Fid's ref= erence count drops to zero (i.e., it
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0has been clunked and= there are no outstanding requests
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0referring to it), de= stroyfid is called to allow the
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0program to dispose o= f the fid->aux pointer.


Thanks for your help! I'd tried us= ing destroyfid to achieve what I need but failed. I tried today again imple= ment with destroyfid but realized that it will not fully support what I nee= d.

I'm using a file server for exchange data b= etween 9P clients. When a new file is created, I create a plan9 channel and= two threads (one for handle reads and other for writes), a write(2) to the= file is translated into a sendp and a read(2) is translated into a recvp o= n the channel. The channel could be buffered or not, and then I want to mai= ntain data allocated (aux related data) anyway, because the file server is = a queueing system when channel have a buffer bigger than zero.
Apart from that, I want to know how many clients have each fil= e opened to update my stats file. It's possible in any way without a cl= unk callback?

I'm trying to replace a rabbitmq= server with this system, but I have a requirement for some way of monitori= ng of queues size, performance of channels, number of clients connected to = each channel (file on dchan), etc, I need this kind of information for make= a comparison with the current queue system... =C2=A0

<= div>Thanks!

--
cinap


--001a114432ae7bd651052acd834f-- From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 References: In-Reply-To: From: Skip Tavakkolian Date: Tue, 2 Feb 2016 19:15:29 +0000 Message-ID: To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=001a114336b0b76c62052ace5349 Subject: Re: [9fans] Fwd: lib9p: Add clunk callback to Srv struct Topicbox-Message-UUID: 81f20d10-ead9-11e9-9d60-3106f5b1d025 --001a114336b0b76c62052ace5349 Content-Type: text/plain; charset=UTF-8 i'd recommend studying 9pserve.c in plan9port. On Tue, Feb 2, 2016 at 10:17 AM Tiago Natel wrote: > 2016-02-01 20:03 GMT-02:00 : > >> > Is there a reason why lib9p doesn't have a clunk function pointer in >> Srv struct? >> >> what about Srv.destroyfid()? >> >> Destroyfid >> When a Fid's reference count drops to zero (i.e., it >> has been clunked and there are no outstanding requests >> referring to it), destroyfid is called to allow the >> program to dispose of the fid->aux pointer. >> >> > Thanks for your help! I'd tried using destroyfid to achieve what I need > but failed. I tried today again implement with destroyfid but realized that > it will not fully support what I need. > > I'm using a file server for exchange data between 9P clients. When a new > file is created, I create a plan9 channel and two threads (one for handle > reads and other for writes), a write(2) to the file is translated into a > sendp and a read(2) is translated into a recvp on the channel. The channel > could be buffered or not, and then I want to maintain data allocated (aux > related data) anyway, because the file server is a queueing system when > channel have a buffer bigger than zero. > > Apart from that, I want to know how many clients have each file opened to > update my stats file. It's possible in any way without a clunk callback? > > I'm trying to replace a rabbitmq server with this system, but I have a > requirement for some way of monitoring of queues size, performance of > channels, number of clients connected to each channel (file on dchan), etc, > I need this kind of information for make a comparison with the current > queue system... > > Thanks! > > -- >> cinap >> >> --001a114336b0b76c62052ace5349 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
i'd recommend studying 9pserve.c in plan9port.
On Tue, Feb 2, 2016 at 10:17 = AM Tiago Natel <tiago.natel= @neoway.com.br> wrote:
2016-02-0= 1 20:03 GMT-02:00 <cinap_lenrek@felloff.net>:
> Is there a reason why lib9p doesn= 9;t have a clunk function pointer in Srv struct?

what about Srv.destroyfid()?

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Destroyfid
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0When a Fid's ref= erence count drops to zero (i.e., it
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0has been clunked and= there are no outstanding requests
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0referring to it), de= stroyfid is called to allow the
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0program to dispose o= f the fid->aux pointer.


Thanks for your help! I&= #39;d tried using destroyfid to achieve what I need but failed. I tried tod= ay again implement with destroyfid but realized that it will not fully supp= ort what I need.

I'm using a file server for e= xchange data between 9P clients. When a new file is created, I create a pla= n9 channel and two threads (one for handle reads and other for writes), a w= rite(2) to the file is translated into a sendp and a read(2) is translated = into a recvp on the channel. The channel could be buffered or not, and then= I want to maintain data allocated (aux related data) anyway, because the f= ile server is a queueing system when channel have a buffer bigger than zero= .

Apart from that, I want to know how many clients= have each file opened to update my stats file. It's possible in any wa= y without a clunk callback?

I'm trying to repl= ace a rabbitmq server with this system, but I have a requirement for some w= ay of monitoring of queues size, performance of channels, number of clients= connected to each channel (file on dchan), etc, I need this kind of inform= ation for make a comparison with the current queue system... =C2=A0

Thanks!

--
cinap

--001a114336b0b76c62052ace5349-- From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <53efcb3de52d8327fb42f54b6a5a1c08@felloff.net> Date: Wed, 3 Feb 2016 02:25:39 +0100 From: cinap_lenrek@felloff.net To: 9fans@9fans.net In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] Fwd: lib9p: Add clunk callback to Srv struct Topicbox-Message-UUID: 820a5640-ead9-11e9-9d60-3106f5b1d025 > I'm using a file server for exchange data between 9P clients. When a new > file is created, I create a plan9 channel and two threads (one for handle > reads and other for writes), a write(2) to the file is translated into a > sendp and a read(2) is translated into a recvp on the channel. The channel > could be buffered or not, and then I want to maintain data allocated (aux > related data) anyway, because the file server is a queueing system when > channel have a buffer bigger than zero. It is hard to say without seeing the code, but this construction sounds wrong as recvp() in Srv.read would block the 9p read loop causing you to not process any other 9p requests when one client is blocked in a read. You also want to handle flushes otherwise you cannot interrupt/cancel the blocked read. You can handle this by chaining the Req's that you cannot satisfy immidiately in a linked list and respond to them from some other proc or thread once you have data the client could read. What do you mean by client? You could have multiple Srv's with each client having its own network connection to it. Or it could mean multiple attaches (mounts) and a single Srv. Or you it could mean you mean *someone* reading the file and the state about a "Client" is in the Fid. Anyway, it sounds like the problem you'r having with destroyfid() is that it doenst give you access to information whoever is the client of the file closed no? -- cinap From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: <53efcb3de52d8327fb42f54b6a5a1c08@felloff.net> References: <53efcb3de52d8327fb42f54b6a5a1c08@felloff.net> Date: Wed, 3 Feb 2016 09:53:04 -0200 Message-ID: From: Tiago Natel To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=001a1140d744c718b8052adc4258 Subject: Re: [9fans] Fwd: lib9p: Add clunk callback to Srv struct Topicbox-Message-UUID: 820ed22e-ead9-11e9-9d60-3106f5b1d025 --001a1140d744c718b8052adc4258 Content-Type: text/plain; charset=UTF-8 2016-02-02 23:25 GMT-02:00 : > > > It is hard to say without seeing the code, but this construction sounds > wrong > as recvp() in Srv.read would block the 9p read loop causing you to > not process any other 9p requests when one client is blocked in a read. > You also want to handle flushes otherwise you cannot interrupt/cancel > the blocked read. You can handle this by chaining the Req's that you > cannot satisfy immidiately in a linked list and respond to them from some > other proc or thread once you have data the client could read. > Source code: hg clone https://bitbucket.org/tiago4orion/dchan Well, I'm doing a lot of tests with simultaneous access and everything 'appears' to works as expected. I'm using threadlistensrv/threadpostmountsrv to handle each new 9P connection in a separate thread. When a new client creates a file, the file server creates a Channel and two additional threads (one for block the reads, and one for block the writes) that will enqueue (reqqueuepush) the related requests. See here: Create a new file (or dchan channel): fs.c:497,507 When someone attempts to write to this file: fs.c:/^fswrite The request will be enqueued in the f->aux->wq (Reqqueue*) executing the function syncwrite on the writer thread of this file. The fs.c:/^syncwrite will send the r->ifcall.data in the channel associated with the file (f->aux->chan) and it will block the writer thread (of this specific file) until someother 9P client attempts to read the file. The read is similar, but happens in the syncread function. That way I'm able to create multiple clients: plan9: cpu% mount -c /srv/dchan /n/dchan Linux: # mount -t 9p -o port=6666 ip.of.dchan /n/dchan # cd /n/dchan # touch pipeline The command above will create two associated with this specific file. # cat pipeline The command above will block in the recvp call in the reader thread of this file, until someone writes something in it. cpu% cd /n/dchan cpu% ls ctl stats pipeline cpu% echo AAAAAAAAAAAAA >> pipeline The command above will issue a sendp in the same channel on the writer thread. The linux box will receive (recvp) the data and block in the next read(2). That's the workflow. > > What do you mean by client? By client I mean a 9P connection: mount -c /srv/dchan /n/dchan > You could have multiple Srv's with each > client having its own network connection to it. I'm using thread*srv function to achieve this. It's correct, isn't? > Or it could mean multiple > attaches (mounts) and a single Srv. Or you it could mean you mean *someone* > reading the file and the state about a "Client" is in the Fid. Anyway, > it sounds like the problem you'r having with destroyfid() is that it doenst > give you access to information whoever is the client of the file closed no? > Yes, I don't know if I understodd what you mean, but yeah, I need the information when someone closed the file (stopped reading the Channel). Thanks > > -- > cinap > > --001a1140d744c718b8052adc4258 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
2016= -02-02 23:25 GMT-02:00 <cinap_lenrek@felloff.net>:
It is hard to say without seeing the code, but this construction sou= nds wrong
as recvp() in Srv.read would block the 9p read loop causing you to
not process any other 9p requests when one client is blocked in a read.
You also want to handle flushes otherwise you cannot interrupt/cancel
the blocked read. You can handle this by chaining the Req's that you cannot satisfy immidiately in a linked list and respond to them from some other proc or thread once you have data the client could read.

=C2=A0Source code: hg clone https://bitbucket.org/tiago4orion/dchan

Well, I'm doing a lot of tests with simultaneous= access and everything 'appears' to works as expected.
I&= #39;m using threadlistensrv/threadpostmountsrv to handle each new 9P connec= tion in a separate thread.

When a new client creat= es a file, the file server creates a Channel and two additional threads (on= e for block the reads, and one for block the writes) that will enqueue (req= queuepush) the related requests. See here:

Create = a new file (or dchan channel): fs.c:497,507

When s= omeone attempts to write to this file: fs.c:/^fswrite
The request= will be enqueued in the f->aux->wq (Reqqueue*) executing the functio= n syncwrite on the writer thread of this file.

The= fs.c:/^syncwrite will send the r->ifcall.data in the channel associated= with the file (f->aux->chan) and it will block the writer thread (of= this specific file) until someother 9P client attempts to read the file. T= he read is similar, but happens in the syncread function.

That way I'm able to create multiple clients:

plan9:
cpu% mount -c /srv/dchan /n/dchan

Linux:
# mount -t 9p -o port=3D6666 ip.of.dchan /n/dchan=

# cd /n/dchan
# touch pipeline
The command above will create two associated with this specific file.

# cat pipeline
The command above will block= in the recvp call in the reader thread of this file, until someone writes = something in it.

cpu% cd /n/dchan
cpu% l= s
ctl stats pipeline
cpu% echo AAAAAAAAAAAAA >> p= ipeline

The command above will issue a sendp in th= e same channel on the writer thread. The linux box will receive (recvp) the= data and block in the next read(2).

That's th= e workflow.

What do you mean by client?

By client I me= an a 9P connection: mount -c /srv/dchan /n/dchan
=C2=A0
You could have multiple Srv's with each
client having its own network connection to it.

I'm using thread*srv function to achieve this. It's correct, = isn't?
=C2=A0
Or it could mean multiple=
attaches (mounts) and a single Srv. Or you it could mean you mean *someone*=
reading the file and the state about a "Client" is in the Fid. An= yway,
it sounds like the problem you'r having with destroyfid() is that it do= enst
give you access to information whoever is the client of the file closed no?=

=C2=A0Yes, I don't know if I under= stodd what you mean, but yeah, I need the information when someone closed t= he file (stopped reading the Channel).

Thanks

--
cinap


--001a1140d744c718b8052adc4258--