Commit 166c58d5 authored by Pavel Emelyanov's avatar Pavel Emelyanov

img: Mark unbufferred images

We have some images that store raw data together with
the pb objects (and one that just stores raw data) and
use custom access to this. E.g. pipe-data images splice
data into them and sk-queue one lseeks the image for
queue packets.

For those using buffered mode mixed with raw may lead
to troubles. Explicitly mark such images, so that the
buffering (next patches) handle such images carefully.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
Acked-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent cf64851b
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "image-desc.h" #include "image-desc.h"
#include "cr-show.h" #include "cr-show.h"
#include "magic.h" #include "magic.h"
#include "image.h"
/* /*
* The cr fd set is the set of files where the information * The cr fd set is the set of files where the information
...@@ -17,6 +18,13 @@ ...@@ -17,6 +18,13 @@
.magic = _name##_MAGIC, \ .magic = _name##_MAGIC, \
} }
#define FD_ENTRY_F(_name, _fmt, _f) \
[CR_FD_##_name] = { \
.fmt = _fmt ".img", \
.magic = _name##_MAGIC, \
.oflags = _f, \
}
struct cr_fd_desc_tmpl imgset_template[CR_FD_MAX] = { struct cr_fd_desc_tmpl imgset_template[CR_FD_MAX] = {
FD_ENTRY(INVENTORY, "inventory"), FD_ENTRY(INVENTORY, "inventory"),
FD_ENTRY(FDINFO, "fdinfo-%d"), FD_ENTRY(FDINFO, "fdinfo-%d"),
...@@ -38,16 +46,16 @@ struct cr_fd_desc_tmpl imgset_template[CR_FD_MAX] = { ...@@ -38,16 +46,16 @@ struct cr_fd_desc_tmpl imgset_template[CR_FD_MAX] = {
FD_ENTRY(MM, "mm-%d"), FD_ENTRY(MM, "mm-%d"),
FD_ENTRY(VMAS, "vmas-%d"), FD_ENTRY(VMAS, "vmas-%d"),
FD_ENTRY(PIPES, "pipes"), FD_ENTRY(PIPES, "pipes"),
FD_ENTRY(PIPES_DATA, "pipes-data"), FD_ENTRY_F(PIPES_DATA, "pipes-data", O_NOBUF), /* splices data */
FD_ENTRY(FIFO, "fifo"), FD_ENTRY(FIFO, "fifo"),
FD_ENTRY(FIFO_DATA, "fifo-data"), FD_ENTRY_F(FIFO_DATA, "fifo-data", O_NOBUF), /* the same */
FD_ENTRY(PSTREE, "pstree"), FD_ENTRY(PSTREE, "pstree"),
FD_ENTRY(SIGACT, "sigacts-%d"), FD_ENTRY(SIGACT, "sigacts-%d"),
FD_ENTRY(UNIXSK, "unixsk"), FD_ENTRY(UNIXSK, "unixsk"),
FD_ENTRY(INETSK, "inetsk"), FD_ENTRY(INETSK, "inetsk"),
FD_ENTRY(PACKETSK, "packetsk"), FD_ENTRY(PACKETSK, "packetsk"),
FD_ENTRY(NETLINK_SK, "netlinksk"), FD_ENTRY(NETLINK_SK, "netlinksk"),
FD_ENTRY(SK_QUEUES, "sk-queues"), FD_ENTRY_F(SK_QUEUES, "sk-queues", O_NOBUF), /* lseeks the image */
FD_ENTRY(ITIMERS, "itimers-%d"), FD_ENTRY(ITIMERS, "itimers-%d"),
FD_ENTRY(POSIX_TIMERS, "posix-timers-%d"), FD_ENTRY(POSIX_TIMERS, "posix-timers-%d"),
FD_ENTRY(CREDS, "creds-%d"), FD_ENTRY(CREDS, "creds-%d"),
...@@ -58,22 +66,22 @@ struct cr_fd_desc_tmpl imgset_template[CR_FD_MAX] = { ...@@ -58,22 +66,22 @@ struct cr_fd_desc_tmpl imgset_template[CR_FD_MAX] = {
FD_ENTRY(IPCNS_SEM, "ipcns-sem-%d"), FD_ENTRY(IPCNS_SEM, "ipcns-sem-%d"),
FD_ENTRY(FS, "fs-%d"), FD_ENTRY(FS, "fs-%d"),
FD_ENTRY(REMAP_FPATH, "remap-fpath"), FD_ENTRY(REMAP_FPATH, "remap-fpath"),
FD_ENTRY(GHOST_FILE, "ghost-file-%x"), FD_ENTRY_F(GHOST_FILE, "ghost-file-%x", O_NOBUF),
FD_ENTRY(TCP_STREAM, "tcp-stream-%x"), FD_ENTRY(TCP_STREAM, "tcp-stream-%x"),
FD_ENTRY(MNTS, "mountpoints-%d"), FD_ENTRY(MNTS, "mountpoints-%d"),
FD_ENTRY(NETDEV, "netdev-%d"), FD_ENTRY(NETDEV, "netdev-%d"),
FD_ENTRY(IFADDR, "ifaddr-%d"), FD_ENTRY_F(IFADDR, "ifaddr-%d", O_NOBUF),
FD_ENTRY(ROUTE, "route-%d"), FD_ENTRY_F(ROUTE, "route-%d", O_NOBUF),
FD_ENTRY(IPTABLES, "iptables-%d"), FD_ENTRY_F(IPTABLES, "iptables-%d", O_NOBUF),
FD_ENTRY(TMPFS_IMG, "tmpfs-%d.tar.gz"), FD_ENTRY_F(TMPFS_IMG, "tmpfs-%d.tar.gz", O_NOBUF),
FD_ENTRY(TMPFS_DEV, "tmpfs-dev-%d.tar.gz"), FD_ENTRY_F(TMPFS_DEV, "tmpfs-dev-%d.tar.gz", O_NOBUF),
FD_ENTRY(TTY_FILES, "tty"), FD_ENTRY(TTY_FILES, "tty"),
FD_ENTRY(TTY_INFO, "tty-info"), FD_ENTRY(TTY_INFO, "tty-info"),
FD_ENTRY(FILE_LOCKS, "filelocks"), FD_ENTRY(FILE_LOCKS, "filelocks"),
FD_ENTRY(RLIMIT, "rlimit-%d"), FD_ENTRY(RLIMIT, "rlimit-%d"),
FD_ENTRY(PAGES, "pages-%u"), FD_ENTRY_F(PAGES, "pages-%u", O_NOBUF),
FD_ENTRY(PAGES_OLD, "pages-%d"), FD_ENTRY_F(PAGES_OLD, "pages-%d", O_NOBUF),
FD_ENTRY(SHM_PAGES_OLD, "pages-shmem-%ld"), FD_ENTRY_F(SHM_PAGES_OLD, "pages-shmem-%ld", O_NOBUF),
FD_ENTRY(SIGNAL, "signal-s-%d"), FD_ENTRY(SIGNAL, "signal-s-%d"),
FD_ENTRY(PSIGNAL, "signal-p-%d"), FD_ENTRY(PSIGNAL, "signal-p-%d"),
FD_ENTRY(TUNFILE, "tunfile"), FD_ENTRY(TUNFILE, "tunfile"),
......
...@@ -211,7 +211,8 @@ struct cr_img *open_image_at(int dfd, int type, unsigned long flags, ...) ...@@ -211,7 +211,8 @@ struct cr_img *open_image_at(int dfd, int type, unsigned long flags, ...)
if (!img) if (!img)
goto errn; goto errn;
flags &= ~O_OPT; oflags |= imgset_template[type].oflags;
flags &= ~(O_OPT | O_NOBUF);
va_start(args, flags); va_start(args, flags);
vsnprintf(path, PATH_MAX, imgset_template[type].fmt, args); vsnprintf(path, PATH_MAX, imgset_template[type].fmt, args);
......
...@@ -101,6 +101,7 @@ enum { ...@@ -101,6 +101,7 @@ enum {
struct cr_fd_desc_tmpl { struct cr_fd_desc_tmpl {
const char *fmt; /* format for the name */ const char *fmt; /* format for the name */
u32 magic; /* magic in the header */ u32 magic; /* magic in the header */
int oflags; /* flags for image_open */
}; };
extern struct cr_fd_desc_tmpl imgset_template[CR_FD_MAX]; extern struct cr_fd_desc_tmpl imgset_template[CR_FD_MAX];
......
...@@ -69,10 +69,12 @@ ...@@ -69,10 +69,12 @@
extern bool fdinfo_per_id; extern bool fdinfo_per_id;
extern bool ns_per_id; extern bool ns_per_id;
#define O_OPT (O_PATH)
#define O_NOBUF (O_DIRECT)
#define O_DUMP (O_RDWR | O_CREAT | O_TRUNC) #define O_DUMP (O_RDWR | O_CREAT | O_TRUNC)
#define O_SHOW (O_RDONLY) #define O_SHOW (O_RDONLY | O_NOBUF)
#define O_RSTR (O_RDONLY) #define O_RSTR (O_RDONLY)
#define O_OPT (O_PATH)
struct cr_img { struct cr_img {
int _fd; int _fd;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment