* [PATCH 1/5] Tools: hv: vss: Skip freezing filesystems backed by loop
2017-08-06 20:12 [PATCH 0/5] Drivers: hv: Miscellaneous fixes kys
@ 2017-08-06 20:12 ` kys
2017-08-06 20:12 ` [PATCH 2/5] Drivers: hv: balloon: Correctly update onlined page count kys
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: kys @ 2017-08-06 20:12 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang,
leann.ogasawara, marcelo.cerri, sthemmin
Cc: Alex Ng, Vyronas Tsingaras, K. Y. Srinivasan
From: Alex Ng <alexng@messages.microsoft.com>
Since a loop device is backed by a file, a backup will already result in
its parent filesystem being frozen. It's sufficient to just freeze the
parent filesystem, so we can skip the loop device.
This avoids a situation where a loop device and its parent filesystem are
both frozen and then thawed out of order. For example, if the loop device
is enumerated first, we would thaw it while its parent filesystem is still
frozen. The thaw operation fails and the loop device remains frozen.
Signed-off-by: Alex Ng <alexng@messages.microsoft.com>
Signed-off-by: Vyronas Tsingaras <vyronas@vtsingaras.me>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
tools/hv/hv_vss_daemon.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/tools/hv/hv_vss_daemon.c b/tools/hv/hv_vss_daemon.c
index 7ba5419..b2b4ebf 100644
--- a/tools/hv/hv_vss_daemon.c
+++ b/tools/hv/hv_vss_daemon.c
@@ -21,6 +21,7 @@
#include <sys/types.h>
#include <sys/poll.h>
#include <sys/ioctl.h>
+#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <mntent.h>
@@ -30,6 +31,7 @@
#include <ctype.h>
#include <errno.h>
#include <linux/fs.h>
+#include <linux/major.h>
#include <linux/hyperv.h>
#include <syslog.h>
#include <getopt.h>
@@ -70,6 +72,7 @@ static int vss_operate(int operation)
char match[] = "/dev/";
FILE *mounts;
struct mntent *ent;
+ struct stat sb;
char errdir[1024] = {0};
unsigned int cmd;
int error = 0, root_seen = 0, save_errno = 0;
@@ -92,6 +95,10 @@ static int vss_operate(int operation)
while ((ent = getmntent(mounts))) {
if (strncmp(ent->mnt_fsname, match, strlen(match)))
continue;
+ if (stat(ent->mnt_fsname, &sb) == -1)
+ continue;
+ if (S_ISBLK(sb.st_mode) && major(sb.st_rdev) == LOOP_MAJOR)
+ continue;
if (hasmntopt(ent, MNTOPT_RO) != NULL)
continue;
if (strcmp(ent->mnt_type, "vfat") == 0)
--
1.7.1
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 2/5] Drivers: hv: balloon: Correctly update onlined page count
2017-08-06 20:12 [PATCH 0/5] Drivers: hv: Miscellaneous fixes kys
2017-08-06 20:12 ` [PATCH 1/5] Tools: hv: vss: Skip freezing filesystems backed by loop kys
@ 2017-08-06 20:12 ` kys
2017-08-06 20:12 ` [PATCH 3/5] Drivers: hv: balloon: Show the max dynamic memory assigned kys
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: kys @ 2017-08-06 20:12 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang,
leann.ogasawara, marcelo.cerri, sthemmin
Cc: Alex Ng, K. Y. Srinivasan
From: Alex Ng <alexng@messages.microsoft.com>
Previously, num_pages_onlined was updated using value from memory online
notifier. This is incorrect because they assume that all hot-added pages
are online, even though we only online the amount that's backed by the
host. We should update num_pages_onlined only when the balloon driver
marks a page as online.
Signed-off-by: Alex Ng <alexng@messages.microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
drivers/hv/hv_balloon.c | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
index f5728de..0a5c318 100644
--- a/drivers/hv/hv_balloon.c
+++ b/drivers/hv/hv_balloon.c
@@ -584,10 +584,6 @@ static int hv_memory_notifier(struct notifier_block *nb, unsigned long val,
switch (val) {
case MEM_ONLINE:
- spin_lock_irqsave(&dm_device.ha_lock, flags);
- dm_device.num_pages_onlined += mem->nr_pages;
- spin_unlock_irqrestore(&dm_device.ha_lock, flags);
- /* Fall through */
case MEM_CANCEL_ONLINE:
if (dm_device.ha_waiting) {
dm_device.ha_waiting = false;
@@ -644,6 +640,9 @@ static void hv_page_online_one(struct hv_hotadd_state *has, struct page *pg)
__online_page_set_limits(pg);
__online_page_increment_counters(pg);
__online_page_free(pg);
+
+ WARN_ON_ONCE(!spin_is_locked(&dm_device.ha_lock));
+ dm_device.num_pages_onlined++;
}
static void hv_bring_pgs_online(struct hv_hotadd_state *has,
--
1.7.1
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 3/5] Drivers: hv: balloon: Show the max dynamic memory assigned
2017-08-06 20:12 [PATCH 0/5] Drivers: hv: Miscellaneous fixes kys
2017-08-06 20:12 ` [PATCH 1/5] Tools: hv: vss: Skip freezing filesystems backed by loop kys
2017-08-06 20:12 ` [PATCH 2/5] Drivers: hv: balloon: Correctly update onlined page count kys
@ 2017-08-06 20:12 ` kys
2017-08-06 20:12 ` [PATCH 4/5] Drivers: hv: balloon: Initialize last_post_time on startup kys
2017-08-06 20:12 ` [PATCH 5/5] Drivers: hv: kvp: Use MAX_ADAPTER_ID_SIZE for translating adapter id kys
4 siblings, 0 replies; 6+ messages in thread
From: kys @ 2017-08-06 20:12 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang,
leann.ogasawara, marcelo.cerri, sthemmin
Cc: Alex Ng, K. Y. Srinivasan
From: Alex Ng <alexng@messages.microsoft.com>
Previously we were only showing max number of pages. We should make it
more clear that this value is the max amount of dynamic memory that the
Hyper-V host is willing to assign to this guest.
Signed-off-by: Alex Ng <alexng@messages.microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
drivers/hv/hv_balloon.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
index 0a5c318..7cec482 100644
--- a/drivers/hv/hv_balloon.c
+++ b/drivers/hv/hv_balloon.c
@@ -1035,8 +1035,8 @@ static void process_info(struct hv_dynmem_device *dm, struct dm_info_msg *msg)
if (info_hdr->data_size == sizeof(__u64)) {
__u64 *max_page_count = (__u64 *)&info_hdr[1];
- pr_info("INFO_TYPE_MAX_PAGE_CNT = %llu\n",
- *max_page_count);
+ pr_info("Max. dynamic memory size: %llu MB\n",
+ (*max_page_count) >> (20 - PAGE_SHIFT));
}
break;
--
1.7.1
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 4/5] Drivers: hv: balloon: Initialize last_post_time on startup
2017-08-06 20:12 [PATCH 0/5] Drivers: hv: Miscellaneous fixes kys
` (2 preceding siblings ...)
2017-08-06 20:12 ` [PATCH 3/5] Drivers: hv: balloon: Show the max dynamic memory assigned kys
@ 2017-08-06 20:12 ` kys
2017-08-06 20:12 ` [PATCH 5/5] Drivers: hv: kvp: Use MAX_ADAPTER_ID_SIZE for translating adapter id kys
4 siblings, 0 replies; 6+ messages in thread
From: kys @ 2017-08-06 20:12 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang,
leann.ogasawara, marcelo.cerri, sthemmin
Cc: Alex Ng, K. Y. Srinivasan
From: Alex Ng <alexng@messages.microsoft.com>
When left uninitialized, this sometimes fails the following check in
post_status():
if (!time_after(now, (last_post_time + HZ))) {
return;
}
This causes unnecessary delays in reporting memory pressure to host after
booting up.
Signed-off-by: Alex Ng <alexng@messages.microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
drivers/hv/hv_balloon.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
index 7cec482..db0e665 100644
--- a/drivers/hv/hv_balloon.c
+++ b/drivers/hv/hv_balloon.c
@@ -1655,6 +1655,7 @@ static int balloon_probe(struct hv_device *dev,
}
dm_device.state = DM_INITIALIZED;
+ last_post_time = jiffies;
return 0;
--
1.7.1
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 5/5] Drivers: hv: kvp: Use MAX_ADAPTER_ID_SIZE for translating adapter id
2017-08-06 20:12 [PATCH 0/5] Drivers: hv: Miscellaneous fixes kys
` (3 preceding siblings ...)
2017-08-06 20:12 ` [PATCH 4/5] Drivers: hv: balloon: Initialize last_post_time on startup kys
@ 2017-08-06 20:12 ` kys
4 siblings, 0 replies; 6+ messages in thread
From: kys @ 2017-08-06 20:12 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang,
leann.ogasawara, marcelo.cerri, sthemmin
Cc: Alex Ng, K. Y. Srinivasan
From: Alex Ng <alexng@messages.microsoft.com>
There's a bug which passes the output buffer size as MAX_IP_ADDR_SIZE,
when converting the adapter_id field to UTF16. This is much larger than
the actual size (MAX_ADAPTER_ID_SIZE). Fix this by passing the proper
size.
Fortunately, the translation is limited by the length of the input. This
explains why we haven't seen output buffer overflow conditions.
Signed-off-by: Alex Ng <alexng@messages.microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
drivers/hv/hv_kvp.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/hv/hv_kvp.c b/drivers/hv/hv_kvp.c
index 9a90b91..5eed1e7 100644
--- a/drivers/hv/hv_kvp.c
+++ b/drivers/hv/hv_kvp.c
@@ -304,7 +304,7 @@ static int process_ob_ipinfo(void *in_msg, void *out_msg, int op)
strlen((char *)in->body.kvp_ip_val.adapter_id),
UTF16_HOST_ENDIAN,
(wchar_t *)out->kvp_ip_val.adapter_id,
- MAX_IP_ADDR_SIZE);
+ MAX_ADAPTER_ID_SIZE);
if (len < 0)
return len;
--
1.7.1
^ permalink raw reply [flat|nested] 6+ messages in thread