public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Stanislav Kinsbursky <skinsbursky@parallels.com>
To: "akpm@linux-foundation.org" <akpm@linux-foundation.org>
Cc: Pavel Emelyanov <xemul@parallels.com>,
	"serge.hallyn@canonical.com" <serge.hallyn@canonical.com>,
	"criu@openvz.org" <criu@openvz.org>,
	"arnd@arndb.de" <arnd@arndb.de>,
	"lucas.demarchi@profusion.mobi" <lucas.demarchi@profusion.mobi>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"dhowells@redhat.com" <dhowells@redhat.com>,
	"mtk.manpages@gmail.com" <mtk.manpages@gmail.com>
Subject: [CRIU] [PATCH v2 2/4] ipc: move all checkpoint-restore code under appropriate define
Date: Tue, 10 Apr 2012 17:27:47 +0400	[thread overview]
Message-ID: <4F843553.3090004@parallels.com> (raw)
In-Reply-To: <4F833CDF.4080300@parallels.com>

v2: added dummy compat_do_msg_peek_all() and do_msg_peek_all() functions used in 
case of CONFIG_CHECKPOINT_RESTORE is not defined.

All new checkpoint/restore code parts are now covered with
CONFIG_CHECKPOINT_RESTORE macro. So it would be easy to remove them, in case
the whole project fails.

---
  ipc/compat.c |    8 +++++++-
  ipc/msg.c    |   15 +++++++++++++++
  2 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/ipc/compat.c b/ipc/compat.c
index 96cb9db..87317ff 100644
--- a/ipc/compat.c
+++ b/ipc/compat.c
@@ -334,7 +334,7 @@ long compat_sys_msgsnd(int first, int second, int third, 
void __user *uptr)
         return do_msgsnd(first, type, up->mtext, second, third);
  }

-
+#ifdef CONFIG_CHECKPOINT_RESTORE
  static long compat_do_msg_peek_all(void __user *dest, struct msg_msg *msg, 
size_t bufsz)
  {
         struct compat_msgbuf_a __user *msgp = dest;
@@ -354,6 +354,12 @@ static long compat_do_msg_peek_all(void __user *dest, 
struct msg_msg *msg, size_
                 return -EFAULT;
         return msgsz;
  }
+#else
+static long compat_do_msg_peek_all(void __user *dest, struct msg_msg *msg, 
size_t bufsz)
+{
+       return -EINVAL;
+}
+#endif

  long compat_do_msg_fill(void __user *dest, struct msg_msg *msg, size_t bufsz)
  {
diff --git a/ipc/msg.c b/ipc/msg.c
index 017bf0b..af08fe6 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -762,6 +762,7 @@ static inline int convert_mode(long *msgtyp, int msgflg)
         return SEARCH_EQUAL;
  }

+#ifdef CONFIG_CHECKPOINT_RESTORE
  static long do_msg_peek_all(void __user *dest, struct msg_msg *msg, size_t bufsz)
  {
         struct msgbuf_a __user *msgp = dest;
@@ -788,6 +789,12 @@ static long do_msg_peek_all(void __user *dest, struct 
msg_msg *msg, size_t bufsz
                 return -EFAULT;
         return msgsz;
  }
+#else
+static long do_msg_peek_all(void __user *dest, struct msg_msg *msg, size_t bufsz)
+{
+       return -EINVAL;
+}
+#endif

  static long do_msg_fill(void __user *dest, struct msg_msg *msg, size_t bufsz)
  {
@@ -811,7 +818,9 @@ long do_msgrcv(int msqid, void __user *buf, size_t bufsz, 
long msgtyp,
         struct msg_msg *msg;
         int mode;
         struct ipc_namespace *ns;
+#ifdef CONFIG_CHECKPOINT_RESTORE
         size_t arrsz = bufsz;
+#endif

         if (msqid < 0 || (long) bufsz < 0)
                 return -EINVAL;
@@ -845,6 +854,7 @@ long do_msgrcv(int msqid, void __user *buf, size_t bufsz, 
long msgtyp,
                                                 walk_msg->m_type != 1) {
                                         msg = walk_msg;
                                         msgtyp = walk_msg->m_type - 1;
+#ifdef CONFIG_CHECKPOINT_RESTORE
                                 } else if (msgflg & MSG_PEEK_ALL) {
                                         long ret;

@@ -855,6 +865,7 @@ long do_msgrcv(int msqid, void __user *buf, size_t bufsz, 
long msgtyp,
                                         }
                                         buf += ret;
                                         arrsz -= ret;
+#endif
                                 } else {
                                         msg = walk_msg;
                                         break;
@@ -863,8 +874,10 @@ long do_msgrcv(int msqid, void __user *buf, size_t bufsz, 
long msgtyp,
                         tmp = tmp->next;
                 }
                 if (!IS_ERR(msg)) {
+#ifdef CONFIG_CHECKPOINT_RESTORE
                         if (msgflg & MSG_PEEK_ALL)
                                 goto out_unlock;
+#endif
                         /*
                          * Found a suitable message.
                          * Unlink it from the queue.
@@ -959,8 +972,10 @@ out_unlock:
         if (IS_ERR(msg))
                 return PTR_ERR(msg);

+#ifdef CONFIG_CHECKPOINT_RESTORE
         if (msgflg & MSG_PEEK_ALL)
                 return bufsz - arrsz;
+#endif

         bufsz = msg_fill(buf, msg, bufsz);
         free_msg(msg);

  parent reply	other threads:[~2012-04-10 13:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-09 17:53 [PATCH 0/4] IPC: message queue checkpoint/restore - requested updates Stanislav Kinsbursky
2012-04-09 17:53 ` [PATCH 1/4] ipc: rename obfuscating MSG_STEAL flag into MSG_PEEK_ALL Stanislav Kinsbursky
2012-04-09 17:54 ` [PATCH 2/4] ipc: move all checkpoint-restore code under appropriate define Stanislav Kinsbursky
2012-04-09 19:47   ` [CRIU] " Pavel Emelyanov
2012-04-10  9:05     ` Stanislav Kinsbursky
2012-04-10 13:27     ` Stanislav Kinsbursky [this message]
2012-04-09 17:54 ` [PATCH 3/4] ipc: handle MSG_PEEK_ALL flag if CONFIG_CHECKPOINT_RESTORE is dropped Stanislav Kinsbursky
2012-04-09 17:54 ` [PATCH 4/4] test: IPC message queue migration test Stanislav Kinsbursky
2012-04-10 19:17   ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F843553.3090004@parallels.com \
    --to=skinsbursky@parallels.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=criu@openvz.org \
    --cc=dhowells@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucas.demarchi@profusion.mobi \
    --cc=mtk.manpages@gmail.com \
    --cc=serge.hallyn@canonical.com \
    --cc=xemul@parallels.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox