0

I am trying to make changes in the nfsv3 client fs kernel module in linux. I am able to compile the kernel modules.

sureshbabu@sureshbabu-virtual-machine:~/linux-hwe-5.11-5.11.0$ make -C . M=./fs/nfs
make: Entering directory '/home/sureshbabu/linux-hwe-5.11-5.11.0'
  CC [M]  fs/nfs/filelayout/filelayout.o
  CC [M]  fs/nfs/filelayout/filelayoutdev.o
  LD [M]  fs/nfs/filelayout/nfs_layout_nfsv41_files.o
  CC [M]  fs/nfs/blocklayout/blocklayout.o
  CC [M]  fs/nfs/blocklayout/dev.o
  CC [M]  fs/nfs/blocklayout/extent_tree.o
  CC [M]  fs/nfs/blocklayout/rpc_pipefs.o
  LD [M]  fs/nfs/blocklayout/blocklayoutdriver.o
  CC [M]  fs/nfs/flexfilelayout/flexfilelayout.o
  CC [M]  fs/nfs/flexfilelayout/flexfilelayoutdev.o
  LD [M]  fs/nfs/flexfilelayout/nfs_layout_flexfiles.o
  CC [M]  fs/nfs/client.o
  CC [M]  fs/nfs/dir.o
  CC [M]  fs/nfs/file.o
  CC [M]  fs/nfs/getroot.o
  CC [M]  fs/nfs/inode.o
  CC [M]  fs/nfs/super.o
  CC [M]  fs/nfs/io.o
  CC [M]  fs/nfs/direct.o
  CC [M]  fs/nfs/pagelist.o
  CC [M]  fs/nfs/read.o
  CC [M]  fs/nfs/symlink.o
  CC [M]  fs/nfs/unlink.o
  CC [M]  fs/nfs/write.o
  CC [M]  fs/nfs/namespace.o
  CC [M]  fs/nfs/mount_clnt.o
  CC [M]  fs/nfs/nfstrace.o
  CC [M]  fs/nfs/export.o
  CC [M]  fs/nfs/sysfs.o
  CC [M]  fs/nfs/fs_context.o
  CC [M]  fs/nfs/sysctl.o
  CC [M]  fs/nfs/fscache.o
  CC [M]  fs/nfs/fscache-index.o
  LD [M]  fs/nfs/nfs.o
  CC [M]  fs/nfs/nfs2super.o
  CC [M]  fs/nfs/proc.o
  CC [M]  fs/nfs/nfs2xdr.o
  LD [M]  fs/nfs/nfsv2.o
  CC [M]  fs/nfs/nfs3super.o
  CC [M]  fs/nfs/nfs3client.o
  CC [M]  fs/nfs/nfs3proc.o
  CC [M]  fs/nfs/nfs3xdr.o
  CC [M]  fs/nfs/nfs3acl.o
  LD [M]  fs/nfs/nfsv3.o
  CC [M]  fs/nfs/nfs4proc.o
  CC [M]  fs/nfs/nfs4xdr.o
  CC [M]  fs/nfs/nfs4state.o
  CC [M]  fs/nfs/nfs4renewd.o
  CC [M]  fs/nfs/nfs4super.o
  CC [M]  fs/nfs/nfs4file.o
  CC [M]  fs/nfs/delegation.o
  CC [M]  fs/nfs/nfs4idmap.o
  CC [M]  fs/nfs/callback.o
  CC [M]  fs/nfs/callback_xdr.o
  CC [M]  fs/nfs/callback_proc.o
  CC [M]  fs/nfs/nfs4namespace.o
  CC [M]  fs/nfs/nfs4getroot.o
  CC [M]  fs/nfs/nfs4client.o
  CC [M]  fs/nfs/nfs4session.o
  CC [M]  fs/nfs/dns_resolve.o
  CC [M]  fs/nfs/nfs4trace.o
  CC [M]  fs/nfs/nfs4sysctl.o
  CC [M]  fs/nfs/pnfs.o
  CC [M]  fs/nfs/pnfs_dev.o
  CC [M]  fs/nfs/pnfs_nfs.o
  CC [M]  fs/nfs/nfs42proc.o
  CC [M]  fs/nfs/nfs42xattr.o
  LD [M]  fs/nfs/nfsv4.o
  MODPOST fs/nfs/Module.symvers
  CC [M]  fs/nfs/blocklayout/blocklayoutdriver.mod.o
  LD [M]  fs/nfs/blocklayout/blocklayoutdriver.ko
  CC [M]  fs/nfs/filelayout/nfs_layout_nfsv41_files.mod.o
  LD [M]  fs/nfs/filelayout/nfs_layout_nfsv41_files.ko
  CC [M]  fs/nfs/flexfilelayout/nfs_layout_flexfiles.mod.o
  LD [M]  fs/nfs/flexfilelayout/nfs_layout_flexfiles.ko
  CC [M]  fs/nfs/nfs.mod.o
  LD [M]  fs/nfs/nfs.ko
  CC [M]  fs/nfs/nfsv2.mod.o
  LD [M]  fs/nfs/nfsv2.ko
  CC [M]  fs/nfs/nfsv3.mod.o
  LD [M]  fs/nfs/nfsv3.ko
  CC [M]  fs/nfs/nfsv4.mod.o
  LD [M]  fs/nfs/nfsv4.ko
make: Leaving directory '/home/sureshbabu/linux-hwe-5.11-5.11.0'
sureshbabu@sureshbabu-virtual-machine:~/linux-hwe-5.11-5.11.0$ sudo insmod ./fs/nfs/nfs.ko 
insmod: ERROR: could not insert module ./fs/nfs/nfs.ko: Invalid module format

Dmesg error:

[635761.547511] module: x86/modules: Skipping invalid relocation target, existing value is nonzero for type 1, loc 0000000099c593ab, val ffffffffc08ac356

suresh
  • 4,084
  • 10
  • 44
  • 59
  • "Since nfs.ko depends on fscache.ko I built fscache.ko" - This is strange intention to separately build a module shipped with the kernel itself. If the kernel already has given driver (fscache) as a module, then just reuse this module. If the kernel has given driver as builtin, then just use it as builtin. If the kernel has not given driver at all, then you need to reconfigure whole kernel for enable given driver. The configuration option `FSCACHE` is responsible for that driver. What is value of that option in your kernel? – Tsyvarev Nov 24 '21 at 08:54
  • BTW, your error is specifically about fscahe module. Why you title the question with nfs client? – Tsyvarev Nov 24 '21 at 08:59
  • As you mentioned I loaded the fscache module from the kernel inbuilt version. Now When I try to load the my custom built nfs.ko module. I get the same error Invalid module format error. sureshbabu@sureshbabu-virtual-machine:~/linux-hwe-5.11-5.11.0$ sudo insmod ./fs/nfs/nfs.ko insmod: ERROR: could not insert module ./fs/nfs/nfs.ko: Invalid module format – suresh Nov 24 '21 at 16:44
  • I don't understand why i get the invalid module format error. I downloaded the same source code version and same linux headers version. I build the nfs.ko module using command "make -C . M=./fs/nfs" . – suresh Nov 24 '21 at 16:45
  • "I downloaded the same source code version and same linux headers version." - You need also to use same **configuration options** as your running kernel. Achieving same configuration options as an existing kernel could be a tricky process. Actually, you could just **build a new kernel**, and load it instead of the one you currently use. – Tsyvarev Nov 24 '21 at 17:00
  • I copied the same .config file used by the current kernel.. sureshbabu@sureshbabu-virtual-machine:~/linux-hwe-5.11-5.11.0$ cp /boot/config-5.11.0-40-generic .config . Still same invalid module format error after clean build of the nfs.ko – suresh Nov 24 '21 at 17:17

0 Answers0