You are not logged in.

#1 2015-10-15 19:10:08

lano1106
Member
From: Canada, Montreal
Registered: 2012-11-22
Posts: 95
Website

Best way to modify nfsd max_block_size value

Hi,

The default max_block_size on my machine is 512KB and this is what is expected for a machine having exactly 4GB of RAM based on my understanding of this piece of code:

kernel fs/nfsd/nfssvc.c

static int nfsd_get_default_max_blksize(void)
{
        struct sysinfo i;
        unsigned long long target;
        unsigned long ret;

        si_meminfo(&i);
        target = (i.totalram - i.totalhigh) << PAGE_SHIFT;
        /*
         * Aim for 1/4096 of memory per thread This gives 1MB on 4Gig
         * machines, but only uses 32K on 128M machines.  Bottom out at
         * 8K on 32M and smaller.  Of course, this is only a default.
         */
        target >>= 12;

        ret = NFSSVC_MAXBLKSIZE;
        while (ret > target && ret >= 8*1024*2)
                ret /= 2;
        return ret;
}

I came up with one of my first systemd service file so I just wanted to get some feedback to be sure that I'm approaching my problem the right way.

/etc/systemd/system/multi-user.target.wants/nfs-server-config.service

[Unit]
Description=NFS server config
Requires= proc-fs-nfsd.mount

After= proc-fs-nfsd.mount
Before= nfs-server.service

[Service]
Type=oneshot
RemainAfterExit=no
ExecStart=/usr/bin/bash -c '/usr/bin/echo 1048576 > /proc/fs/nfsd/max_block_size'

thank you,

Last edited by lano1106 (2015-10-15 19:11:07)

Offline

#2 2015-10-15 19:43:29

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: Best way to modify nfsd max_block_size value

I think what you're ultimately trying to do with the service should be done with tmpfiles. See tmpfiles.d(5)

Granted it wouldn't be tied to nfs-server.service in any way, but there's really no harm in that.


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#3 2015-10-15 19:51:21

lano1106
Member
From: Canada, Montreal
Registered: 2012-11-22
Posts: 95
Website

Re: Best way to modify nfsd max_block_size value

alphaminer, I have read about tmpfiles during my reasearch but the timing is crucial.

It need to be done after proc-fs-nfsd.mount is mounted and before rpc.nfsd is launched. Only during this window, you can modify the nfsd parameters. Is this something that can be guaranteed with tmpfiles?

Offline

#4 2015-10-15 20:35:12

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: Best way to modify nfsd max_block_size value

Sorry, I didn't realize the necessity. Tmpfiles can't do that AFAIK.

One issue with your service file then: you should put it in /etc/systemd/system. The subfolders there are for symlinks to enabled services. It also seems there should be a better way than calling " bash -c 'echo ...' ", but I don't have any idea what that would be.

Last edited by alphaniner (2015-10-15 20:35:45)


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

Board footer

Powered by FluxBB