LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-24-2010, 11:06 AM   #1
jamescondron
Member
 
Registered: Jul 2007
Location: Scunthorpe, UK
Distribution: Ubuntu 8.10; Gentoo; Debian Lenny
Posts: 961

Rep: Reputation: 70
Fuse Programming in Perl; buffersize issues


As the post suggests, I'm having some issues with Fuse and perl, namely the write_buffer size. Now, this could just be a Fuse issue, and if it is I'd ask a mod to move this, but I don't think it is.

The background;
Firstly, my implementation is working, and working well. I'm getting reasonable consistency in my read/writes, even with different sizes, and so I'm pretty sure my perl is working well (Which is why I haven't posted any of it, I can if you need).

I've implemented a very simple, bog standard filesystem with hashrefs, and data structures, all looks good. The problem is that the writes are being done in 4096 blocks; the Fuse standard.

Because this is the fuse standard, I did a grep for the write size:
Code:
root@jcmain:~# !1810
grep -inH max_write `locate fuse` 2>/dev/null
/usr/include/fuse/fuse_common.h:105:    unsigned max_write;
/usr/include/linux/fuse.h:363:  __u32   max_write;
Binary file /usr/lib/libfuse.a matches
Binary file /usr/lib/libfuse.so matches
Binary file /usr/lib/libfuse.so.2 matches
Binary file /usr/lib/libfuse.so.2.7.4 matches
/usr/src/linux-2.6.30-custom/debian/linux-headers-2.6.30-custom/usr/src/linux-headers-2.6.30-custom/include/linux/fuse.h:401:   __u32   max_write;
/usr/src/linux-2.6.30-custom/fs/fuse/file.c:786:                bytes = min_t(size_t, bytes, fc->max_write - count);
/usr/src/linux-2.6.30-custom/fs/fuse/file.c:823:        } while (iov_iter_count(ii) && count < fc->max_write &&
/usr/src/linux-2.6.30-custom/fs/fuse/file.c:987:        size_t nmax = write ? fc->max_write : fc->max_read;
/usr/src/linux-2.6.30-custom/fs/fuse/fuse_i.h:322:      unsigned max_write;
/usr/src/linux-2.6.30-custom/fs/fuse/inode.c:763:               fc->max_write = arg->minor < 5 ? 4096 : arg->max_write;
/usr/src/linux-2.6.30-custom/fs/fuse/inode.c:764:               fc->max_write = max_t(unsigned, 4096, fc->max_write);
/usr/src/linux-2.6.30-custom/include/linux/fuse.h:401:  __u32   max_write;
/usr/src/linux-2.6.32.8/fs/fuse/cuse.c:321:     fc->max_write = max_t(unsigned, arg->max_write, 4096);
/usr/src/linux-2.6.32.8/fs/fuse/file.c:819:             bytes = min_t(size_t, bytes, fc->max_write - count);
/usr/src/linux-2.6.32.8/fs/fuse/file.c:859:     } while (iov_iter_count(ii) && count < fc->max_write &&
/usr/src/linux-2.6.32.8/fs/fuse/file.c:1023:    size_t nmax = write ? fc->max_write : fc->max_read;
/usr/src/linux-2.6.32.8/fs/fuse/fuse_i.h:330:   unsigned max_write;
/usr/src/linux-2.6.32.8/fs/fuse/inode.c:831:            fc->max_write = arg->minor < 5 ? 4096 : arg->max_write;
/usr/src/linux-2.6.32.8/fs/fuse/inode.c:832:            fc->max_write = max_t(unsigned, 4096, fc->max_write);
/usr/src/linux-2.6.32.8/include/linux/fuse.h:456:       __u32   max_write;
/usr/src/linux-2.6.32.8/include/linux/fuse.h:474:       __u32   max_write;
/usr/src/linux-headers-2.6.26-2-686/include/linux/fuse.h:363:   __u32   max_write;
/usr/src/linux-headers-2.6.26-2-common/include/linux/fuse.h:363:        __u32   max_write;
root@jcmain:~# uname -a
Linux jcmain 2.6.30-custom #1 SMP Fri Jun 12 22:15:25 BST 2009 i686 GNU/Linux
and found the module which referenced 4096 on my kernel; /usr/src/linux-2.6.30-custom/fs/fuse/inode.c

I changed 4096 to 131072 (I forget why that number, I think I saw it somewhere whilst researching this, but no idea where/why), recompiled the module, unloaded the old fuse module and loaded this one. I was even convinced it'd worked:

Code:
jc@jcmain:~/steg$ sudo perl fs_simple.pl 
unique: 1, opcode: INIT (26), nodeid: 0, insize: 56
INIT: 7.11
flags=0x0000003b
max_readahead=0x00020000
   INIT: 7.8
   flags=0x00000000
   max_readahead=0x00020000
   max_write=0x00020000
   unique: 1, error: 0 (Success), outsize: 40
which as my python prompt tells me:
Code:
>>> int( 0x00020000 )
131072
Which tells me that perl it's self has set the 4096 from somewhere else. Its not, however, built into Fuse.pm or Fuse::Simple.pm - which is what I'm using:

Code:
jc@jcmain:/usr/lib/perl5$ grep 4096 Fuse.pm 
jc@jcmain:/usr/lib/perl5$ 
<snip>
jc@jcmain:/usr/local/share/perl/5.10.0/Fuse$ grep 4096 Simple.pm 
jc@jcmain:/usr/local/share/perl/5.10.0/Fuse$
So what am I missing? Does anyone remember solving the same sort of problem? Can it be solved? Is it even considered a problem, more a feature?

Cheers.
 
Old 03-24-2010, 03:55 PM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
What does the Perl documentation of the modules you are using say on the issue ?
 
Old 03-24-2010, 04:14 PM   #3
jamescondron
Member
 
Registered: Jul 2007
Location: Scunthorpe, UK
Distribution: Ubuntu 8.10; Gentoo; Debian Lenny
Posts: 961

Original Poster
Rep: Reputation: 70
Nothing; the main Fuse module implements nothing, and Fuse::Simple implements all the read functions, with a basic write() subroutine designed to return True each time (or pretty much).

Thats using perldoc and by going through the source for both.
 
Old 03-24-2010, 09:05 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
You could try asking the Perl gurus over at perlmonks.org or possibly even emailing the module maintainer. I did that once for a Threads module. Just be polite; you might be pleasantly surprised
 
Old 03-25-2010, 03:57 AM   #5
jamescondron
Member
 
Registered: Jul 2007
Location: Scunthorpe, UK
Distribution: Ubuntu 8.10; Gentoo; Debian Lenny
Posts: 961

Original Poster
Rep: Reputation: 70
Probably a good idea, cheers Chris
 
Old 03-26-2010, 06:55 PM   #6
jamescondron
Member
 
Registered: Jul 2007
Location: Scunthorpe, UK
Distribution: Ubuntu 8.10; Gentoo; Debian Lenny
Posts: 961

Original Poster
Rep: Reputation: 70
As a follow up
(since I know how annoyed I get reading old posts that don't do this)

as per: http://perlmonks.org/?node_id=830830.

Perl uses a 4096 sized buffer which is changeable, at compilation, though it is never explained why the perl hash append stuff uses the same buffer as the IO stuff (or even if it does), but who knows.

But yes, a hat tip to Chris for reminding me about perlmonks and the community. Hopefully the link there will help out. Hopefully the answer also.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
inquiry to Perl monks about Perl as a first programming language mannclay Programming 53 03-22-2009 01:35 PM
Perl installation issues mod /cpan issues knockout_artist Linux - Newbie 2 05-14-2008 06:55 PM
FUSE works but fuse group does not exist? violagirl23 Linux - Software 3 01-21-2008 04:01 AM
RHEL4u2 perl localtime() call issues (perl & glibc) Brad.Scalio@noaa.gov Linux - Enterprise 3 01-23-2007 09:27 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration