summaryrefslogtreecommitdiff
path: root/src/readahead
AgeCommit message (Collapse)Author
2014-08-03Unify parse_argv styleZbigniew Jędrzejewski-Szmek
getopt is usually good at printing out a nice error message when commandline options are invalid. It distinguishes between an unknown option and a known option with a missing arg. It is better to let it do its job and not use opterr=0 unless we actually want to suppress messages. So remove opterr=0 in the few places where it wasn't really useful. When an error in options is encountered, we should not print a lengthy help() and overwhelm the user, when we know precisely what is wrong with the commandline. In addition, since help() prints to stdout, it should not be used except when requested with -h or --help. Also, simplify things here and there.
2014-07-31Always prefer our headers to system headersZbigniew Jędrzejewski-Szmek
In practice this shouldn't make much difference, but sometimes our headers might be newer, and we want to test them.
2014-06-22readahead: avoid gcc warning about formatZbigniew Jędrzejewski-Szmek
src/readahead/readahead-common.c:55:17: warning: format ‘%zu’ expects argument of type ‘size_t’, but argument 7 has type ‘__off64_t’ [-Wformat=] log_debug("Not preloading file %s with size out of bounds %zu", fn, st->st_size); ^
2014-06-22consistently order cleanup attribute before typeThomas Hindoe Paaboel Andersen
2014-05-16man: readahead: fix cmdline switch inconsistency between readahead.c and docsAlison Chaiken
Source code has "files-max" and XML has --max-files.
2014-05-16readahead: modernizationsLennart Poettering
2014-05-15readahead: add test to show fs_on_ssd() resultZbigniew Jędrzejewski-Szmek
2014-05-15Remove unnecessary casts in printfsZbigniew Jędrzejewski-Szmek
No functional change expected :)
2014-04-21implement a union to pad out file_handleDave Reisner
Cases where name_to_handle_at is used allocated the full struct to be MAX_HANDLE_SZ, and assigned this size to handle_bytes. This is wrong since handle_bytes should describe the length of the flexible array member and not the whole struct. Define a union type which includes sufficient padding to allow assignment of MAX_HANDLE_SZ to be correct.
2014-03-18util: replace close_nointr_nofail() by a more useful safe_close()Lennart Poettering
safe_close() automatically becomes a NOP when a negative fd is passed, and returns -1 unconditionally. This makes it easy to write lines like this: fd = safe_close(fd); Which will close an fd if it is open, and reset the fd variable correctly. By making use of this new scheme we can drop a > 200 lines of code that was required to test for non-negative fds or to reset the closed fd variable afterwards.
2014-01-31util: use alloca0() intead of alloca() + memzero()Lennart Poettering
2014-01-31use memzero(foo, length); for all memset(foo, 0, length); callsGreg KH
In trying to track down a stupid linker bug, I noticed a bunch of memset() calls that should be using memzero() to make it more "obvious" that the options are correct (i.e. 0 is not the length, but the data to set). So fix up all current calls to memset(foo, 0, length) to memzero(foo, length).
2013-11-06clients: unify how we invoke getopt_long()Lennart Poettering
Among other things this makes sure we always expose a --version command and show it in the help texts.
2013-10-13Introduce udev object cleanup functionsZbigniew Jędrzejewski-Szmek
2013-10-13ModernizationZbigniew Jędrzejewski-Szmek
Fixes minor leak in error path in device.c.
2013-10-13Never call qsort on potentially NULL arraysZbigniew Jędrzejewski-Szmek
This extends 62678ded 'efi: never call qsort on potentially NULL arrays' to all other places where qsort is used and it is not obvious that the count is non-zero.
2013-08-20Rename F_TYPE_CMP() to F_TYPE_EQUAL()Zbigniew Jędrzejewski-Szmek
2013-08-16build-sys: Add configure check for linux/btrfs.hMichael Marineau
btrfs.h was added to uapi in Linux 3.9. To fix building with older header versions this adds a configure check for the header and re-adds btrfs definitions to missing.h which was removed in bed2e820 along with two other ioctls used by gpt-auto-generator. [ Apparently, btrfs.h was only added recently: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=55e301fd57a6239ec14b91a1cf2e70b3dd135194 let's re-add it for now -- kay ]
2013-08-13missing: use btrfs.h instead of defining our own btrfs structuresLennart Poettering
2013-04-25readahead: fix format string issueZbigniew Jędrzejewski-Szmek
(struct stat).st is off_t, which usually is a long, or a long long. There's no good format string modifier for it, so use a cast.
2013-04-24readahead: be more verbose about creation failuresZbigniew Jędrzejewski-Szmek
systemd-readahead reports "Failed to create shared memory segment: No such file or directory", but it's unclear how it can happen. Be more verbose about failures.
2013-04-24Add set_consume which always takes ownershipZbigniew Jędrzejewski-Szmek
Freeing in error path is the common pattern with set_put().
2013-04-19Reintroduce f_type comparison macroHarald Hoyer
This reverts commit 4826f0b7b5c0aefa08b8cc7ef64d69027f84da2c. Because statfs.t_type can be int on some architecures, we have to cast the const magic to the type, otherwise the compiler warns about signed/unsigned comparison, because the magic can be 32 bit unsigned. statfs(2) man page is also wrong on some systems, because f_type is not __SWORD_TYPE on some architecures. The following program: int main(int argc, char**argv) { struct statfs s; statfs(argv[1], &s); printf("sizeof(f_type) = %d\n", sizeof(s.f_type)); printf("sizeof(__SWORD_TYPE) = %d\n", sizeof(__SWORD_TYPE)); printf("sizeof(long) = %d\n", sizeof(long)); printf("sizeof(int) = %d\n", sizeof(int)); if (sizeof(s.f_type) == sizeof(int)) { printf("f_type = 0x%x\n", s.f_type); } else { printf("f_type = 0x%lx\n", s.f_type); } return 0; } executed on s390x gives for a btrfs: sizeof(f_type) = 4 sizeof(__SWORD_TYPE) = 8 sizeof(long) = 8 sizeof(int) = 4 f_type = 0x9123683e
2013-04-18Revert f_type fixupsHarald Hoyer
This reverts commit a858b64dddf79177e12ed30f5e8c47a1471c8bfe. This reverts commit aea275c43194b6ac519ef907b62c5c995050fde0. This reverts commit fc6e6d245ee3989c222a2a8cc82a33475f9922f3. This reverts commit c4073a27c555aeceac87a3b02a83141cde641a1e. This reverts commit cddf148028f525be8176e7f1cbbf4f862bd287f6. This reverts commit 8c68a70170b31f93c287f29fd06c6c17edaf19ad. The constants are now casted to __SWORD_TYPE, which should resolve the compiler warnings about signed vs unsigned. After talking to Kay, we concluded: This should be fixed in the kernel, not worked around in userspace tools. Architectures cannot use int and expect magic constants lager than INT_MAX to work correctly. The kernel header needs to be fixed. Even coreutils cannot handle it: #define RAMFS_MAGIC 0x858458f6 # stat -f -c%t / ffffffff858458f6 #define BTRFS_SUPER_MAGIC 0x9123683E # stat -f -c%t /mnt ffffffff9123683e Although I found the perfect working macro to fix the thing :) __extension__ ({ \ bool _ret = false; \ switch(f) { case c: _ret=true; }; \ ( _ret ); \ })
2013-04-18move _cleanup_ attribute in front of the typeHarald Hoyer
http://lists.freedesktop.org/archives/systemd-devel/2013-April/010510.html
2013-04-18rename CMP_F_TYPE to F_TYPE_CMPHarald Hoyer
2013-04-18Add ugly CMP_F_TYPE() macroHarald Hoyer
On some architectures (like s390x) the kernel has the type int for f_type, but long in userspace. Assigning the 32 bit magic constants from linux/magic.h to the 31 bit signed f_type in the kernel, causes f_type to be negative for some constants. glibc extends the int to long for those architecures in 64 bit mode, so the negative int becomes a negative long, which cannot be simply compared to the original magic constant, because the compiler would automatically cast the constant to long. To workaround this issue, we also compare to the (int)MAGIC value in a macro. Of course, we could do #ifdef with the architecure, but it has to be maintained, and the magic constants are 32 bit anyway. Someday, when the int is unsigned or long for all architectures, we can remove this macro again. Until then, keep it as simple as it can be.
2013-04-17fixup for cddf148028f52Harald Hoyer
Instead of making a type up, just use __SWORD_TYPE, after reading statfs(2). Too bad, this does not fix s390x because __SWORD_TYPE is (long int) and the kernel uses (int) to fill in the field!!!!!!
2013-04-17fixup 8c68a7017 and cast to (unsigned long)Harald Hoyer
2013-04-17fixed statfs.f_type signed vs unsigned comparisonsHarald Hoyer
statfs.f_type is signed but the filesystem magics are unsigned. Casting the magics to signed will not make the signed. Problem seen on big-endian 64bit s390x with __fsword_t 8 bytes. Casting statfs.f_type to unsigned on the other hand will get us what we need. https://bugzilla.redhat.com/show_bug.cgi?id=953217
2013-04-14readahead-analyze: avoid division-by-0Zbigniew Jędrzejewski-Szmek
Also remove a few casts and use _cleanup_fclose_ to simplify logic.
2013-04-11errno is positiveZbigniew Jędrzejewski-Szmek
Make sure we compare errno against positive error codes. The ones in hwclock.c and install.c can have an impact, the rest are unlikely to be hit or in code that isn't widely used. Also check that errno > 0, to help gcc know that we are returning a negative error code.
2013-04-05Use initalization instead of explicit zeroingZbigniew Jędrzejewski-Szmek
Before, we would initialize many fields twice: first by filling the structure with zeros, and then a second time with the real values. We can let the compiler do the job for us, avoiding one copy. A downside of this patch is that text gets slightly bigger. This is because all zero() calls are effectively inlined: $ size build/.libs/systemd text data bss dec hex filename before 897737 107300 2560 1007597 f5fed build/.libs/systemd after 897873 107300 2560 1007733 f6075 build/.libs/systemd … actually less than 1‰. A few asserts that the parameter is not null had to be removed. I don't think this changes much, because first, it is quite unlikely for the assert to fail, and second, an immediate SEGV is almost as good as an assert.
2013-04-03util: rename parse_usec() to parse_sec() sinds the default unit is secondsLennart Poettering
Internally we store all time values in usec_t, however parse_usec() actually was used mostly to parse values in seconds (unless explicit units were specified to define a different unit). Hence, be clear about this and name the function about what we pass into it, not what we get out of it.
2013-04-03util: rename write_one_line_file() to write_string_file()Lennart Poettering
You can write much more than just one line with this call (and we frequently do), so let's correct the naming.
2013-03-31Partially revert e62d8c394474Zbigniew Jędrzejewski-Szmek
The ~80 chars per line part wasn't well received.
2013-03-31ModernizationZbigniew Jędrzejewski-Szmek
Use _cleanup_ and wrap lines to ~80 chars and such.
2013-03-26readahead: cleanupsAuke Kok
- check for OOM - no need to use floats and round()
2013-03-26readahead: chunk on spinning mediaAuke Kok
Readahead has all sorts of bad side effects depending on your storage media. On rotating disks, it may be degrading startup performance if enough requests are queued spanning linearly over all blocks early at boot, and mount, blkid and friends want to insert reads to the start of these block devices after. The end result is that on spinning disks with ext3/4 that udev and mounts take a very long time, and nothing really happens until readahead is completely finished. This has the net effect that the CPU is almost entirely idle for the entire period that readahead is working. We could have finished starting up quite a lot of services in this time if we were smarter at how we do readahead. This patch sorts all requests into 2 second "chunks" and sub-sorts each chunk by block. This adds a single cross-drive seek per "chunk" but has the benefit that we will have a lot of the blocks we need early on in the boot sequence loaded into memory faster. For a comparison of how before/after bootcharts look (ext4 on a mobile 5400rpm 250GB drive) please look at: http://foo-projects.org/~sofar/blocked-tests/ There are bootcharts in the "before" and "after" folders where you should be able to see that many low-level services finish 5-7 seconds earlier with the patch applied (after).
2013-03-11Remove or indent #define GNU_SOURCEZbigniew Jędrzejewski-Szmek
It is only needed in files designed to be usable in standalone compilation. In those files the #ifdefinery is indented. When compiling in-tree, GNU_SOURCE is always defined, so remove one definition.
2013-02-14honor SELinux labels, when creating and writing config filesHarald Hoyer
Also split out some fileio functions to fileio.c and provide a SELinux aware pendant in fileio-label.c see https://bugzilla.redhat.com/show_bug.cgi?id=881577
2013-02-13Revert "log_error() if inotify_add_watch() fails"Lennart Poettering
This reverts commit 2826d14091e43ed3397d862dee79d09d0115c84e. We never should generate log messages from a library.
2013-02-13log_error() if inotify_add_watch() failsHarald Hoyer
[zj: Reworded message s/to watch/to add watch on/ to make it clear that it was the watch init action that failed, and not the "process of watching". I think this way it'll be clearer to people who don't know what inotify does.]
2013-01-03readahead: don't complain that we cannot precache symlinksLennart Poettering
http://lists.freedesktop.org/archives/systemd-devel/2012-December/007847.html
2012-11-22readahead: properly detect btrfs on SSDLennart Poettering
2012-10-22readahead: fix fd validity checkMichal Schmidt
https://bugzilla.redhat.com/show_bug.cgi?id=868603
2012-09-13readahead: use 20K instead of 16K as temporary request nr bumpLennart Poettering
2012-09-04missing: define name_to_handle_at on our own if it is missingLennart Poettering
2012-09-03readahead: a bit of reformattingLennart Poettering
2012-08-23readahead-analyze: don't call fclose on nullLukas Nykryn