Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 20e029d7 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull UML updates from Richard Weinberger:
 "This pile contains mostly fixes and improvements for issues identified
  by Richard W M Jones while adding UML as backend to libguestfs"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml:
  um: Add irq chip um/mask handlers
  um: prctl: Do not include linux/ptrace.h
  um: Run UML in it's own session.
  um: Cleanup SIGTERM handling
  um: ubd: Introduce submit_request()
  um: ubd: Add REQ_FLUSH suppport
  um: Implement probe_kernel_read()
  um: hostfs: Fix writeback
parents e5c832d5 81bab4c3
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -7,7 +7,6 @@
#ifndef __UM_UBD_USER_H
#ifndef __UM_UBD_USER_H
#define __UM_UBD_USER_H
#define __UM_UBD_USER_H


extern void ignore_sigwinch_sig(void);
extern int start_io_thread(unsigned long sp, int *fds_out);
extern int start_io_thread(unsigned long sp, int *fds_out);
extern int io_thread(void *arg);
extern int io_thread(void *arg);
extern int kernel_fd;
extern int kernel_fd;
+59 −13
Original line number Original line Diff line number Diff line
@@ -41,7 +41,7 @@
#include <os.h>
#include <os.h>
#include "cow.h"
#include "cow.h"


enum ubd_req { UBD_READ, UBD_WRITE };
enum ubd_req { UBD_READ, UBD_WRITE, UBD_FLUSH };


struct io_thread_req {
struct io_thread_req {
	struct request *req;
	struct request *req;
@@ -866,6 +866,7 @@ static int ubd_add(int n, char **error_out)
		goto out;
		goto out;
	}
	}
	ubd_dev->queue->queuedata = ubd_dev;
	ubd_dev->queue->queuedata = ubd_dev;
	blk_queue_flush(ubd_dev->queue, REQ_FLUSH);


	blk_queue_max_segments(ubd_dev->queue, MAX_SG);
	blk_queue_max_segments(ubd_dev->queue, MAX_SG);
	err = ubd_disk_register(UBD_MAJOR, ubd_dev->size, n, &ubd_gendisk[n]);
	err = ubd_disk_register(UBD_MAJOR, ubd_dev->size, n, &ubd_gendisk[n]);
@@ -1238,12 +1239,41 @@ static void prepare_request(struct request *req, struct io_thread_req *io_req,


}
}


/* Called with dev->lock held */
static void prepare_flush_request(struct request *req,
				  struct io_thread_req *io_req)
{
	struct gendisk *disk = req->rq_disk;
	struct ubd *ubd_dev = disk->private_data;

	io_req->req = req;
	io_req->fds[0] = (ubd_dev->cow.file != NULL) ? ubd_dev->cow.fd :
		ubd_dev->fd;
	io_req->op = UBD_FLUSH;
}

static bool submit_request(struct io_thread_req *io_req, struct ubd *dev)
{
	int n = os_write_file(thread_fd, &io_req,
			     sizeof(io_req));
	if (n != sizeof(io_req)) {
		if (n != -EAGAIN)
			printk("write to io thread failed, "
			       "errno = %d\n", -n);
		else if (list_empty(&dev->restart))
			list_add(&dev->restart, &restart);

		kfree(io_req);
		return false;
	}
	return true;
}

/* Called with dev->lock held */
/* Called with dev->lock held */
static void do_ubd_request(struct request_queue *q)
static void do_ubd_request(struct request_queue *q)
{
{
	struct io_thread_req *io_req;
	struct io_thread_req *io_req;
	struct request *req;
	struct request *req;
	int n;


	while(1){
	while(1){
		struct ubd *dev = q->queuedata;
		struct ubd *dev = q->queuedata;
@@ -1259,6 +1289,19 @@ static void do_ubd_request(struct request_queue *q)
		}
		}


		req = dev->request;
		req = dev->request;

		if (req->cmd_flags & REQ_FLUSH) {
			io_req = kmalloc(sizeof(struct io_thread_req),
					 GFP_ATOMIC);
			if (io_req == NULL) {
				if (list_empty(&dev->restart))
					list_add(&dev->restart, &restart);
				return;
			}
			prepare_flush_request(req, io_req);
			submit_request(io_req, dev);
		}

		while(dev->start_sg < dev->end_sg){
		while(dev->start_sg < dev->end_sg){
			struct scatterlist *sg = &dev->sg[dev->start_sg];
			struct scatterlist *sg = &dev->sg[dev->start_sg];


@@ -1273,17 +1316,8 @@ static void do_ubd_request(struct request_queue *q)
					(unsigned long long)dev->rq_pos << 9,
					(unsigned long long)dev->rq_pos << 9,
					sg->offset, sg->length, sg_page(sg));
					sg->offset, sg->length, sg_page(sg));


			n = os_write_file(thread_fd, &io_req,
			if (submit_request(io_req, dev) == false)
					  sizeof(struct io_thread_req *));
			if(n != sizeof(struct io_thread_req *)){
				if(n != -EAGAIN)
					printk("write to io thread failed, "
					       "errno = %d\n", -n);
				else if(list_empty(&dev->restart))
					list_add(&dev->restart, &restart);
				kfree(io_req);
				return;
				return;
			}


			dev->rq_pos += sg->length >> 9;
			dev->rq_pos += sg->length >> 9;
			dev->start_sg++;
			dev->start_sg++;
@@ -1367,6 +1401,17 @@ static void do_io(struct io_thread_req *req)
	int err;
	int err;
	__u64 off;
	__u64 off;


	if (req->op == UBD_FLUSH) {
		/* fds[0] is always either the rw image or our cow file */
		n = os_sync_file(req->fds[0]);
		if (n != 0) {
			printk("do_io - sync failed err = %d "
			       "fd = %d\n", -n, req->fds[0]);
			req->error = 1;
		}
		return;
	}

	nsectors = req->length / req->sectorsize;
	nsectors = req->length / req->sectorsize;
	start = 0;
	start = 0;
	do {
	do {
@@ -1431,7 +1476,8 @@ int io_thread(void *arg)
	struct io_thread_req *req;
	struct io_thread_req *req;
	int n;
	int n;


	ignore_sigwinch_sig();
	os_fix_helper_signals();

	while(1){
	while(1){
		n = os_read_file(kernel_fd, &req,
		n = os_read_file(kernel_fd, &req,
				 sizeof(struct io_thread_req *));
				 sizeof(struct io_thread_req *));
+0 −5
Original line number Original line Diff line number Diff line
@@ -21,11 +21,6 @@
#include "ubd.h"
#include "ubd.h"
#include <os.h>
#include <os.h>


void ignore_sigwinch_sig(void)
{
	signal(SIGWINCH, SIG_IGN);
}

int start_io_thread(unsigned long sp, int *fd_out)
int start_io_thread(unsigned long sp, int *fd_out)
{
{
	int pid, fds[2], err;
	int pid, fds[2], err;
+3 −0
Original line number Original line Diff line number Diff line
@@ -141,6 +141,7 @@ extern int os_seek_file(int fd, unsigned long long offset);
extern int os_open_file(const char *file, struct openflags flags, int mode);
extern int os_open_file(const char *file, struct openflags flags, int mode);
extern int os_read_file(int fd, void *buf, int len);
extern int os_read_file(int fd, void *buf, int len);
extern int os_write_file(int fd, const void *buf, int count);
extern int os_write_file(int fd, const void *buf, int count);
extern int os_sync_file(int fd);
extern int os_file_size(const char *file, unsigned long long *size_out);
extern int os_file_size(const char *file, unsigned long long *size_out);
extern int os_file_modtime(const char *file, unsigned long *modtime);
extern int os_file_modtime(const char *file, unsigned long *modtime);
extern int os_pipe(int *fd, int stream, int close_on_exec);
extern int os_pipe(int *fd, int stream, int close_on_exec);
@@ -200,6 +201,7 @@ extern int os_unmap_memory(void *addr, int len);
extern int os_drop_memory(void *addr, int length);
extern int os_drop_memory(void *addr, int length);
extern int can_drop_memory(void);
extern int can_drop_memory(void);
extern void os_flush_stdout(void);
extern void os_flush_stdout(void);
extern int os_mincore(void *addr, unsigned long len);


/* execvp.c */
/* execvp.c */
extern int execvp_noalloc(char *buf, const char *file, char *const argv[]);
extern int execvp_noalloc(char *buf, const char *file, char *const argv[]);
@@ -233,6 +235,7 @@ extern void setup_machinename(char *machine_out);
extern void setup_hostinfo(char *buf, int len);
extern void setup_hostinfo(char *buf, int len);
extern void os_dump_core(void) __attribute__ ((noreturn));
extern void os_dump_core(void) __attribute__ ((noreturn));
extern void um_early_printk(const char *s, unsigned int n);
extern void um_early_printk(const char *s, unsigned int n);
extern void os_fix_helper_signals(void);


/* time.c */
/* time.c */
extern void idle_sleep(unsigned long long nsecs);
extern void idle_sleep(unsigned long long nsecs);
+1 −1
Original line number Original line Diff line number Diff line
@@ -13,7 +13,7 @@ clean-files :=
obj-y = config.o exec.o exitcode.o irq.o ksyms.o mem.o \
obj-y = config.o exec.o exitcode.o irq.o ksyms.o mem.o \
	physmem.o process.o ptrace.o reboot.o sigio.o \
	physmem.o process.o ptrace.o reboot.o sigio.o \
	signal.o smp.o syscall.o sysrq.o time.o tlb.o trap.o \
	signal.o smp.o syscall.o sysrq.o time.o tlb.o trap.o \
	um_arch.o umid.o skas/
	um_arch.o umid.o maccess.o skas/


obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o
obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o
obj-$(CONFIG_GPROF)	+= gprof_syms.o
obj-$(CONFIG_GPROF)	+= gprof_syms.o
Loading