Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install udev rules to /lib/udev/rules.d #356

Closed
wants to merge 3 commits into from
Closed

Install udev rules to /lib/udev/rules.d #356

wants to merge 3 commits into from

Conversation

kylef
Copy link
Contributor

@kylef kylef commented Aug 6, 2011

From what I understand is that udev now installs rules into /lib/udev/rules.d by default, leaving /etc/udev/rules.d for user rules and overrides only. I would write a patch myself, but this automake stuff doesn't make sense to me.

Perhaps also the 90-zfs rule in dracut should be moved to somewhere else also, this isn't dracut specific, it would be useful to use in mkinitcpio for archlinux. Maybe it could be installed somewhere generic and referenced there from both mkinitcpio and dracut.

@behlendorf
Copy link
Contributor

I agreed, but I don't really have time to work on it at the moment either. I'm trying to focus on some of the remaining core issues.

@kylef
Copy link
Contributor Author

kylef commented Aug 5, 2011

Ok, I will try write a patch for /lib/udev/rules.d, what do you think about the dracut 90-zfs rule?

@behlendorf
Copy link
Contributor

OK, I couldn't resist and put together a quick patch which I'm not fond of. Unfortunately, we can't simply use libdir instead of sysconfdir because it can be defined as /lib64 not /lib. I am instead using bindir which is defined by the the packaging as /lib/udev since the only non-sbin binaries needed are for udev. Unfortunately, this scheme falls apart when not building packages and bindir is defined as /bin. Anyway, this patch at least shows roughly what needs to change.

dc71219478c5fe835cda19dd3636ec636be32049

As for the dracut 90-zfs rule it should be OK to installing it along with the usual udev rules. You would just need to make sure dracut's module-setup.sh is also updated to reference the new location. It might also cause some heartburn for some of the init scripts if they don't handle the case when the module are already loaded (they should).

@kylef
Copy link
Contributor Author

kylef commented Aug 5, 2011

I was just checking how other people do this, lvm2 has additional prefixes for udev.

./configure --help

  --with-udev-prefix=UPREFIX     install udev rule files in UPREFIX [[EPREFIX]]
  --with-udevdir=DIR      udev rules in DIR [[UPREFIX/lib/udev/rules.d]]

Example:

./configure --prefix= --sysconfdir=/etc --localstatedir=/var --datarootdir=/usr/share \
--includedir=/usr/include --with-usrlibdir=/usr/lib --with-udevdir=/lib/udev/rules.d/

@kylef
Copy link
Contributor Author

kylef commented Aug 5, 2011

I read in the commit comment "Unfortunately, this scheme falls apart when not building packages and bindir is defined as /bin.". Are there any default ./configure arguments for package building? The AUR archlinux package just sets --prefix=/usr, the sysconf is even in the wrong place. My own PKGBUILD has --prefix=/usr --sysconfdir=/etc. Should a archlinux PKGBUILD file be included in this repo? Lots of things I would normally put in the distributions package repo (such as init.d scripts, dracut) are in zfs repo.

@behlendorf
Copy link
Contributor

Adding an additional prefixes for udev does seem like the cleanest solution.

@behlendorf
Copy link
Contributor

It really just means you need to pass the following paths to configure which is what the rpm/deb packages do. Although I much prefer the idea of adding additional udev prefixes even if it is more work.

./configure --prefix=/ --bindir=/lib/udev --libexecdir=/usr/libexec --datadir=/usr/share

@kylef
Copy link
Contributor Author

kylef commented Aug 5, 2011

I can't work out what is wrong with c19b315, I am pretty sure everything in udev/rules.d/Makefile.am is correct. I removed the sed because I don't understand what reason it was there for. Unfortunatly it didn't help it build.

@behlendorf
Copy link
Contributor

A few comments about c19b315f404a80078d019fc4da619c442bc154fa .

  • UDEV_AC_CONFIG must be added to ZFS_AC_CONFIG_USER in config/user.m4. This ensures it will be called as part of the userspace configure process. While your at it please update the name for consistency to ZFS_AC_CONFIG_USER_UDEV and the .m4 file name should be user-udev.m4.
  • in Makefile.am you will want to use $(udevdir) instead of ${udevdir}
  • Getting the udev rules installed in the right place is important but they also must correctly reference installed location of the zfs udev helpers (cmd/zvol_id, cmd/zpool_id, cmd/sas_switch_id). These tool will all be currently installed in bindir because we assume it to be set to /lib/udev. If this is no longer the case they must be updated to be installed in /lib/udev and the 'sed' updated accordingly.
  • The reason for the 'sed' (which is important) is detailed in commit b9f27ee

@kylef
Copy link
Contributor Author

kylef commented Aug 6, 2011

I have turned this into a pull request with my changes for both 90-zfs and udev rules. Please remember to run ./autogen.sh.

I have some questions about the dracut support, I do not have a distro which uses dracut so I cannot test.

  • dracut_install zpool_id: Where does it look for zpool_id? Will this work with /lib/udev? (did this work previously for /etc/udev?)
  • There is no dracut_install for sas_switch_id, is this needed?

@behlendorf
Copy link
Contributor

Thanks for working on this and taking care of my concerns above. I've merged it with just a few minor tweaks for things which were originally overlooked.

Merged with a few minor tweaks.

  • Fixed white space in user-udev.m4 to use hard tabs
  • Fixed option names in AC_ARG_WITH(), they must match the --with-* option.
  • Explicitly define _udevdir macro in spec file and pass it to configure using the --with-udevdir option. This makes it explicit and easy to change because we can then rely on the define for the rest of the spec file.

@behlendorf behlendorf closed this in 12d06ba Aug 8, 2011
@behlendorf behlendorf reopened this Aug 8, 2011
@behlendorf
Copy link
Contributor

Reopening. I didn't mean to close this entirely since we still have the dracut changes pending. Concerning your questions I'll going to try and pull Pendor in to this discussion since I'm sure he's the most familiar with dracut.

  • Will dracut_install correctly find the udev helpers when they are installed in /lib/udev/? I'm pretty sure the answer is yes, but I'm not positive.
  • Do we need sas_switch_id? The answer here is that it might be needed by more complicated storage topologies so we should probably bring it in.

@pendor
Copy link
Contributor

pendor commented Aug 9, 2011

By default dracut_install will fall down to inst_binary which looks in {/bin, /sbin, /usr/bin, /usr/sbin} in that order. If the binary isn't in one of those spots, the full path must be specified in the dracut_install call. That will probably necessitate pre-processing module-setup.sh or else modifying it at install to honor the right prefix value. I think it would also require specifying the path where the files should be installed in the initrd (which can be done with a second argument to dracut_install). Default just drops them in /bin, but either the udev rules would need to be modified when the initrd was built or else the binaries would need to be installed at the same paths as they are on the live system.

I don't have sas_switch_id in my initrd's, but I'm running very simple storage configs. I don't see any harm in having it. Subject to the above pathing caveats, dracut_install will be bright enough to pull in any additional libs it might need automatically.

@kylef
Copy link
Contributor Author

kylef commented Aug 9, 2011

I have rebased and fixed dracut, (well, I think its fixed. I am unable to test).

0462030 Fixes a bug where the init.d files wouldn't work depending on the configure options used to build zfs. I included it here to save making another pull request.

prefix=/usr/local
exec_prefix=${prefix}

ZFS="${exec_prefix}/sbin/zfs"
ZPOOL="${exec_prefix}/sbin/zpool"
ZPOOL_CACHE="${prefix}/etc/zfs/zpool.cache"

Unfortunately I didn't catch this before because I set all the paths so this never happened.

@behlendorf
Copy link
Contributor

Yes, I missed this as well. I've pulled fce563d but can you please fix the prefix issue a slightly different way. This is the exact reason for the sed you asked about earlier in rules.d/Makefile.am. See commit b9f27ee. It would be best to fix this the same way, then we don't need to define the prefix and exec_prefix variables in the init scripts.

@behlendorf
Copy link
Contributor

Actually I took a first swing at updating your patchs to use the preferred autoconf approach. The updates patches can be found here. They are basically working however they need most testing to ensure everything is exactly right. This build system work is always trickier than it first appears.

https://github.com/behlendorf/zfs/commits/udev

@pendor
Copy link
Contributor

pendor commented Aug 10, 2011

Brian, I gave your branch a shot in the Gentoo ebuild. Looks like something's trying to install module-setup.sh script twice, and it's tweaking Portage's sandboxing protections:

>>> Install zfs-9999 into /var/tmp/portage/sys-fs/zfs-9999/image/ category sys-fs
make -j5 DESTDIR=/var/tmp/portage/sys-fs/zfs-9999/image/ install 
Making install in dracut
make[1]: Entering directory `/var/tmp/portage/sys-fs/zfs-9999/work/zfs-9999/dracut'
Making install in 90zfs
make[2]: Entering directory `/var/tmp/portage/sys-fs/zfs-9999/work/zfs-9999/dracut/90zfs'
make[3]: Entering directory `/var/tmp/portage/sys-fs/zfs-9999/work/zfs-9999/dracut/90zfs'
make[3]: Nothing to be done for `install-exec-am'.
test -z "/usr/share/dracut/modules.d/90zfs" || /bin/mkdir -p "/var/tmp/portage/sys-fs/zfs-9999/image//usr/share/dracut/modules.d/90zfs"
test -z "/usr/share/dracut/modules.d/90zfs" || /bin/mkdir -p "/var/tmp/portage/sys-fs/zfs-9999/image//usr/share/dracut/modules.d/90zfs"
 /usr/bin/install -c -m 644 ../../dracut/90zfs/module-setup.sh '/var/tmp/portage/sys-fs/zfs-9999/image//usr/share/dracut/modules.d/90zfs'
##### ZSB: I think the line above is where it goes bad as the line below tries to install a bunch of scripts in one go.
 /usr/bin/install -c ../../dracut/90zfs/module-setup.sh ../../dracut/90zfs/mount-zfs.sh ../../dracut/90zfs/parse-zfs.sh '/var/tmp/portage/sys-fs/zfs-9999/image//usr/share/dracut/modules.d/90zfs'
/usr/bin/install: cannot create regular file `/var/tmp/portage/sys-fs/zfs-9999/image//usr/share/dracut/modules.d/90zfs/module-setup.sh': File exists
make[3]: *** [install-dist_pkgdracutSCRIPTS] Error 1
make[3]: Leaving directory `/var/tmp/portage/sys-fs/zfs-9999/work/zfs-9999/dracut/90zfs'
make[2]: *** [install-am] Error 2
make[2]: Leaving directory `/var/tmp/portage/sys-fs/zfs-9999/work/zfs-9999/dracut/90zfs'
make[1]: *** [install-recursive] Error 1
make[1]: Leaving directory `/var/tmp/portage/sys-fs/zfs-9999/work/zfs-9999/dracut'
make: *** [install-recursive] Error 1
emake failed

I'll try to take a closer look in the morning and see if I can get it working. Spent more time than I would have liked this evening getting the trunk builds of SPL & ZFS building in my ebuilds (almost exclusively my fault, not trunk's...).

@kylef
Copy link
Contributor Author

kylef commented Aug 11, 2011

The issue is:

pkgdracut_DATA = $(top_srcdir)/dracut/90zfs/module-setup.sh
dist_pkgdracut_SCRIPTS = \
    $(pkgdracut_DATA) \

module-setup.sh is installed with both pkgdracut_DATA and dist_pkgdracut_SCRIPTS.

A solution could be to rename pkgdracut_DATA to something else, and create a second pkgdracutdir variable to use.

+ pkgdracutinstalldir = $(pkgdracutdir)
- pkgdracut_DATA = $(top_srcdir)/dracut/90zfs/module-setup.sh

+ pkgdracutinstalldir_DATA = $(top_srcdir)/dracut/90zfs/module-setup.sh

dist_pkgdracut_SCRIPTS = \
-   $(pkgdracut_DATA) \

- $(pkgdracut_DATA):
+ $(pkgdracutinstalldir_DATA):

I can't think of any simpler solution.

@behlendorf
Copy link
Contributor

OK, try this. I force updated the branch and made a few fixes. The current branch works well for me but I want to make sure your both happy with it before I merge it. I'm very wary of tinkering with the build system this much without significant testing, it's far to easy to accidentally miss something. That said, I think this is definitely any improvement.

https://github.com/behlendorf/zfs/commits/udev

@pendor
Copy link
Contributor

pendor commented Aug 20, 2011

HEAD from the udev branch built & booted fine on Gentoo. Looks good to me.

@kylef
Copy link
Contributor Author

kylef commented Aug 21, 2011

Looks fine to me also.

@behlendorf
Copy link
Contributor

Merged in to master, thanks for helping me test this.

kernelOfTruth pushed a commit to kernelOfTruth/zfs that referenced this pull request Mar 1, 2015
For small objects the Linux slab allocator has several advantages
over its counterpart in the SPL.  These include:

1) It is more memory-efficient and packs objects more tightly.
2) It is continually tuned to maximize performance.

Therefore it makes sense to layer the SPLs slab allocator on top
of the Linux slab allocator.  This allows us to leverage the
advantages above while preserving the Illumos semantics we depend
on.  However, there are some things we need to be careful of:

1) The Linux slab allocator was never designed to work well with
   large objects.  Because the SPL slab must still handle this use
   case a cut off limit was added to transition from Linux slab
   backed objects to kmem or vmem backed slabs.

   spl_kmem_cache_slab_limit - Objects less than or equal to this
   size in bytes will be backed by the Linux slab.  By default
   this value is zero which disables the Linux slab functionality.
   Reasonable values for this cut off limit are in the range of
   4096-16386 bytes.

   spl_kmem_cache_kmem_limit - Objects less than or equal to this
   size in bytes will be backed by a kmem slab.  Objects over this
   size will be vmem backed instead.  This value defaults to
   1/8 a page, or 512 bytes on an x86_64 architecture.

2) Be aware that using the Linux slab may inadvertently introduce
   new deadlocks.  Care has been taken previously to ensure that
   all allocations which occur in the write path use GFP_NOIO.
   However, there may be internal allocations performed in the
   Linux slab which do not honor these flags.  If this is the case
   a deadlock may occur.

The path forward is definitely to start relying on the Linux slab.
But for that to happen we need to start building confidence that
there aren't any unexpected surprises lurking for us.  And ideally
need to move completely away from using the SPLs slab for large
memory allocations.  This patch is a first step.

NOTES:
1) The KMC_NOMAGAZINE flag was leveraged to support the Linux slab
   backed caches but it is not supported for kmem/vmem backed caches.

2) Regardless of the spl_kmem_cache_*_limit settings a cache may
   be explicitly set to a given type by passed the KMC_KMEM,
   KMC_VMEM, or KMC_SLAB flags during cache creation.

3) The constructors, destructors, and reclaim callbacks are all
   functional and will be called regardless of the cache type.

4) KMC_SLAB caches will not appear in /proc/spl/kmem/slab due to
   the issues involved in presenting correct object accounting.
   Instead they will appear in /proc/slabinfo under the same names.

5) Several kmem SPLAT tests needed to be fixed because they relied
   incorrectly on internal kmem slab accounting.  With the updated
   test cases all the SPLAT tests pass as expected.

6) An autoconf test was added to ensure that the __GFP_COMP flag
   was correctly added to the default flags used when allocating
   a slab.  This is required to ensure all pages in higher order
   slabs are properly refcounted, see ae16ed9.

7) When using the SLUB allocator there is no need to attempt to
   set the __GFP_COMP flag.  This has been the default behavior
   for the SLUB since Linux 2.6.25.

8) When using the SLUB it may be desirable to set the slub_nomerge
   kernel parameter to prevent caches from being merged.

Original-patch-by: DHE <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Signed-off-by: Prakash Surya <[email protected]>
Signed-off-by: Tim Chase <[email protected]>
Signed-off-by: DHE <[email protected]>
Signed-off-by: Chunwei Chen <[email protected]>
Closes openzfs#356
kernelOfTruth pushed a commit to kernelOfTruth/zfs that referenced this pull request Mar 1, 2015
For small objects the Linux slab allocator should be used to make the most
efficient use of the memory.  However, large objects are not supported by
the Linux slab and therefore the SPL implementation is preferred.  A cutoff
of 16K was determined to be optimal for architectures using 4K pages.

Signed-off-by: Brian Behlendorf <[email protected]>
Signed-off-by: DHE <[email protected]>
Issue openzfs#356
Closes openzfs#379
sdimitro pushed a commit to sdimitro/zfs that referenced this pull request May 23, 2022
When we initiate a checkpoint, in `ZettaCache::flush_checkpoint()`, we
need to wait for in-progress reads and writes, to ensure that they are
committed before the checkpoint is committed.

The problem is that after we wait for in-progress i/o, more i/o's can be
initiated before we acquire the zettacache state lock and take the
checkpoint.

By injecting delays and panic's, I was able to cause the agent to die
after the checkpoint was committed (i.e. the superblocks were written)
but before all the writes that should be part of it were completed.
When those blocks are subsequently read, a checksum error is detected
and the zettacache is healed.

This commit solves the problem by waiting for in-progress i/o
(`ZettaCacheState::outstanding_reads/_writes`) while holding the state
lock.  This increases the state lock hold time, although the lockless
wait still reduces the hold time somewhat.  This is not great for
performance, but it's a simple fix.
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request May 18, 2024
Appears to corrupt pool, take safe option until it can be
investigated.

Signed-off-by: Jorgen Lundman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants