Coder Social home page Coder Social logo

Comments (5)

poettering avatar poettering commented on July 23, 2024

These lines are relevant:

May 12 12:08:27 nas systemd-udevd[282449]: sdd: Received inotify event for /dev/sdd.
May 12 12:08:38 nas systemd-udevd[282449]: sdd: device is closed, synthesising 'change' on /sys/devices/pci0000:00/0000:00:02.1/0000:01:00.0/0000:02:08.0/0000:05:00.0/0000:06:00.0/0000:07:00.0/host12/port-12:0/end_device-12:0/target12:0:0/12:0:0:0/block/sdd

So udev watches block devices via inotify for IN_CLOSE_WRITE events: i.e. whenever a block device that was opened by userspace for writing is closed, we'll retrigger the device so that the partition table is reread and similar things.

hence, figure out what tool is responsible for opening the block device writable.

udev itself never opens a block device writable, it just probes it in read-only mode. Hence it must be some other component of your OS. Once you fix that, then udev won't do a thing anymore either.

Closing, since this isn't a systemd problem, but some other tool is triggering this.

from systemd.

zhangyoufu avatar zhangyoufu commented on July 23, 2024

This device is not mounted, and this is a headless server with no such userspace program which would open the block device in write mode (except sg_start itself).

strace shows that sg_start opens the HDD in read-write mode by default. After sg_start closes the fd, systemd-udevd rechecks the partition table which triggers unexpected spin-up.

Fortunately, sg_start has an option --readonly, -r which opens the block device in read-only mode. But still, the interaction between sg_start and systemd-udevd worth some documentation.

I opened an issue in sg3_utils asking if it's possible to make sg_start read-only by default.

from systemd.

mwilck avatar mwilck commented on July 23, 2024

Can you check which command run by udev actually causes the call to sd_revalidate_disk? Is it the scsi_id call?

Fortunately, sg_start has an option --readonly, -r which opens the block device in read-only mode.

Right. Looking at it this way, runningn sg_start --stop without --readonly may be considered a user error. Note that the "nuisance spin-up" is actually mentioned in the sg_start man page.

But still, the interaction between sg_start and systemd-udevd worth some documentation.

udevd's close-after-write behavior is documented, although not very prominently. Search for watch in udev(7). If you don't want this, you can set OPTIONS:="nowatch" in a custom udev rule.

This is not the only use case in which udev's watch mechanism is causing unexpected effects. But there are only very few reports of this kind, so it doesn't seem to be a big problem for most users. OTOH, it makes sure that the OS notices partition table changes, which is a nice feature that would be thoroughly missed by users if it didn't exist.

from systemd.

zhangyoufu avatar zhangyoufu commented on July 23, 2024

Can you check which command run by udev actually causes the call to sd_revalidate_disk? Is it the scsi_id call?

Last time I checked via kernel ftrace, userland process was systemd-udevd. Double checked by commenting out scsi_id line in udev rule file, restart systemd-udevd, and execute sg_start --stop, the issue still exists.

from systemd.

yuwata avatar yuwata commented on July 23, 2024

Yeah, we should check if the disk is stopped before running scsi_id or blkid. But how?

from systemd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.