[systemd-commits] 2 commits - man/systemd.swap.xml man/systemd.target.xml src/macro.h src/readahead-collect.c src/readahead-replay.c src/util.c src/util.h TODO

Lennart Poettering lennart at kemper.freedesktop.org
Mon Mar 28 12:43:41 PDT 2011


 TODO                    |    6 ++++--
 man/systemd.swap.xml    |   23 ++++++++++++++++++++---
 man/systemd.target.xml  |   13 +++++++------
 src/macro.h             |   11 +++--------
 src/readahead-collect.c |    3 ++-
 src/readahead-replay.c  |    2 +-
 src/util.c              |   14 ++++++++++++++
 src/util.h              |    3 +++
 8 files changed, 54 insertions(+), 21 deletions(-)

New commits:
commit 37f85e66e8f396b6f758e063531b95531aef628e
Author: cee1 <fykcee1 at gmail.com>
Date:   Fri Mar 18 10:03:41 2011 +0800

    util: detect page size runtime.
    
    Some architectures support multiple machine types with diffenent
    page sizes, and some machine types even support multiple
    page sizes themselves.

diff --git a/src/macro.h b/src/macro.h
index 996b7c2..e7a4d2c 100644
--- a/src/macro.h
+++ b/src/macro.h
@@ -27,8 +27,6 @@
 #include <sys/uio.h>
 #include <inttypes.h>
 
-#define PAGE_SIZE 4096
-
 #define _printf_attr_(a,b) __attribute__ ((format (printf, a, b)))
 #define _sentinel_ __attribute__ ((sentinel))
 #define _noreturn_ __attribute__((noreturn))
@@ -51,12 +49,9 @@
 #define STRINGIFY(x) XSTRINGIFY(x)
 
 /* Rounds up */
-static inline size_t ALIGN(size_t l) {
-        return ((l + sizeof(void*) - 1) & ~(sizeof(void*) - 1));
-}
-
-static inline size_t PAGE_ALIGN(size_t l) {
-        return ((l + PAGE_SIZE - 1) & ~(PAGE_SIZE -1));
+#define ALIGN(l) ALIGN_TO((l), sizeof(void*))
+static inline size_t ALIGN_TO(size_t l, size_t ali) {
+        return ((l + ali - 1) & ~(ali - 1));
 }
 
 #define ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0]))
diff --git a/src/readahead-collect.c b/src/readahead-collect.c
index ca82271..6937295 100644
--- a/src/readahead-collect.c
+++ b/src/readahead-collect.c
@@ -119,9 +119,10 @@ static int pack_file(FILE *pack, const char *fn, bool on_btrfs) {
                 goto finish;
         }
 
-        pages = l / PAGE_SIZE;
+        pages = l / page_size();
 
         vec = alloca(pages);
+        memset(vec, 0, pages);
         if (mincore(start, l, vec) < 0) {
                 log_warning("mincore(%s) failed: %m", fn);
                 r = -errno;
diff --git a/src/readahead-replay.c b/src/readahead-replay.c
index d2de7ef..3984c36 100644
--- a/src/readahead-replay.c
+++ b/src/readahead-replay.c
@@ -94,7 +94,7 @@ static int unpack_file(FILE *pack) {
                 any = true;
 
                 if (fd >= 0)
-                        if (posix_fadvise(fd, b * PAGE_SIZE, (c - b) * PAGE_SIZE, POSIX_FADV_WILLNEED) < 0) {
+                        if (posix_fadvise(fd, b * page_size(), (c - b) * page_size(), POSIX_FADV_WILLNEED) < 0) {
                                 log_warning("posix_fadvise() failed: %m");
                                 goto finish;
                         }
diff --git a/src/util.c b/src/util.c
index 1febd07..fada69c 100644
--- a/src/util.c
+++ b/src/util.c
@@ -61,6 +61,20 @@
 #include "exit-status.h"
 #include "hashmap.h"
 
+size_t page_size(void) {
+        static __thread size_t pgsz = 0;
+        long r;
+
+        if (pgsz)
+                return pgsz;
+
+        assert_se((r = sysconf(_SC_PAGESIZE)) > 0);
+
+        pgsz = (size_t) r;
+
+        return pgsz;
+}
+
 bool streq_ptr(const char *a, const char *b) {
 
         /* Like streq(), but tries to make sense of NULL pointers */
diff --git a/src/util.h b/src/util.h
index 192ebff..04afc73 100644
--- a/src/util.h
+++ b/src/util.h
@@ -83,6 +83,9 @@ struct timespec *timespec_store(struct timespec *ts, usec_t u);
 usec_t timeval_load(const struct timeval *tv);
 struct timeval *timeval_store(struct timeval *tv, usec_t u);
 
+size_t page_size(void);
+#define PAGE_ALIGN(l) ALIGN_TO((l), page_size())
+
 #define streq(a,b) (strcmp((a),(b)) == 0)
 #define strneq(a, b, n) (strncmp((a), (b), (n)) == 0)
 

commit f9276855a1d270b6c3f857cdaf2c4b49920c2228
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Mar 28 21:36:13 2011 +0200

    man: explain a couple of default dependencies

diff --git a/TODO b/TODO
index 11b9dbb..0db681b 100644
--- a/TODO
+++ b/TODO
@@ -25,12 +25,14 @@ F15:
 
 * NM should pull in network.target, ntpd should pull in rtc-set.target.
 
-* fix sysv parser to add right wants dependencies
-
 * document default dependencies
 
+* remove KillMode=process-group
+
 Features:
 
+* when key file cannot be found, read it from kbd in cryptsetup
+
 * hide passwords on TAB
 
 * get rid of random file name in generator directory?
diff --git a/man/systemd.swap.xml b/man/systemd.swap.xml
index 45f8f40..d95e39e 100644
--- a/man/systemd.swap.xml
+++ b/man/systemd.swap.xml
@@ -68,13 +68,23 @@
                 specific configuration options are configured in the
                 [Swap] section.</para>
 
-                <para>Swap units must be named after the devices they
-                control. Example: the swap device
+                <para>Swap units must be named after the devices
+                (resp. files) they control. Example: the swap device
                 <filename>/dev/sda5</filename> must be configured in a
                 unit file <filename>dev-sda5.swap</filename>. For
                 details about the escaping logic used to convert a
                 file system path to a unit name see
                 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
+
+                <para>All swap units automatically get the appropriate
+                dependencies on the devices (resp. on the mount points
+                of the files) they are actived from.</para>
+
+                <para>Swap units with
+                <varname>DefaultDependencies=</varname> enabled
+                implicitly acquire a conflicting dependency to
+                <filename>umount.target</filename> so that they are
+                deactivated at shutdown.</para>
         </refsect1>
 
         <refsect1>
@@ -88,6 +98,13 @@
                 <para>If a swap device or file is configured in both
                 <filename>/etc/fstab</filename> and a unit file the
                 configuration in the latter takes precedence.</para>
+
+                <para>Unless the <option>noauto</option> option is set
+                for them all swap units configured in
+                <filename>/etc/fstab</filename> are also added as
+                requirements to <filename>swap.target</filename>, so
+                that they are waited for and activated during
+                boot.</para>
         </refsect1>
 
         <refsect1>
@@ -149,7 +166,7 @@
                                 a time span value such as "5min
                                 20s". Pass 0 to disable the timeout
                                 logic. Defaults to
-                                60s.</para></listitem>
+                                3min.</para></listitem>
                         </varlistentry>
 
                         <varlistentry>
diff --git a/man/systemd.target.xml b/man/systemd.target.xml
index 5c26427..6b1dbfb 100644
--- a/man/systemd.target.xml
+++ b/man/systemd.target.xml
@@ -83,14 +83,15 @@
                 <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>
                 for details).</para>
 
-                <para>Unless
-                <varname>DefaultDependencies=</varname> is set to
-                <option>false</option>, target units will
-                implicitly complement all configured dependencies of type
-                <varname>Wants=</varname>,
+                <para>Unless <varname>DefaultDependencies=</varname>
+                is set to <option>false</option>, target units will
+                implicitly complement all configured dependencies of
+                type <varname>Wants=</varname>,
                 <varname>Requires=</varname>,
                 <varname>RequiresOverridable=</varname> with
-                dependencies of type <varname>After=</varname>.
+                dependencies of type <varname>After=</varname> if the
+                units in question also have
+                <varname>DefaultDependencies=true</varname>.
                 </para>
         </refsect1>
 



More information about the systemd-commits mailing list