Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4836810imm; Fri, 18 May 2018 11:29:33 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoS5BUOE2h7gFw+Oxi0dwAkIT9Ax1R1IgW/wxyZDEMGkq/fDCGxSIe/FM4ef+Mft8/OuN77 X-Received: by 2002:a17:902:5602:: with SMTP id h2-v6mr10766155pli.115.1526668173046; Fri, 18 May 2018 11:29:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526668173; cv=none; d=google.com; s=arc-20160816; b=HF+1dSEWNRvtvAxfdt14tGETsQhvfyxmzCrzFvQxduo21H3C5G5IB2jupnqB4DTOvC x+4YMEuAaCu8IvZ/V9yhL055uOWNGoLviJHuDGZ1oBRSVfTF2M9Wy4O96E1ixWtAsljQ n7HAr1+ExwrYJCtjFb6YRFV5qrUPboxQggCk0mmSKnPpBe+rOojd+j/+0jUZAFmXRc/a tkFWevNWGxdM3o7WFKeVt1eO/KoFnrdf7ZyYeJNygs7sS+rcg2SvuM/mi47RtEgq2WEV COtfxpscjuHGmrydXxDMQ/2IngEaWFr6PMzgyscSq1I9riSGhV4Q8qxZS+uuCaXEHmC8 i9ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=BJ/YYsuNIbnrU+VciY8vRtjSRRmZS02NlaSW8WmZSe4=; b=kw24Vihpuka4CdFUflZZVbQ8sPpaENy5OQzgdw/dtGhQdnQOdaLPLQbGvYqMG7o9ji j/3ibdGabca1uIvYqL6TRZuQohJzNsrtBvK0vQ90F7BNTC996SBVyP/eShtYHhyXmf2K cbplFozgfevHoz7O+/5ssSRQjp8t46GNlPNStOKbmHYmSsPPN0NiJlF36SNIowrFvCtv JTbcdwfqBRDoNF2HBnX0ZzOGMlwLcIv4u5QsIAfHWDKnu7EugGH4m8PQf2Jmye3EvGz4 kgpwNlUzIEDRmFPqCVohOPZW+s8T9yoc0u1XGlCuZDqFgqEXSnfhDNuZKNaGW6MoKkAh If7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=o1uaTRdk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 64-v6si8044039pfl.309.2018.05.18.11.29.17; Fri, 18 May 2018 11:29:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=o1uaTRdk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751976AbeERS24 (ORCPT + 99 others); Fri, 18 May 2018 14:28:56 -0400 Received: from mail-qk0-f194.google.com ([209.85.220.194]:42814 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751805AbeERS2y (ORCPT ); Fri, 18 May 2018 14:28:54 -0400 Received: by mail-qk0-f194.google.com with SMTP id b22-v6so7177134qkj.9; Fri, 18 May 2018 11:28:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=BJ/YYsuNIbnrU+VciY8vRtjSRRmZS02NlaSW8WmZSe4=; b=o1uaTRdkHvV9j7E1HbAZwrA0Q39uZo/HRFOjHkV+q7KgzYlybi0sgYcH2Ur1mBEByK ex2O8RrjQYbYpdNfi1AMn31g+JNtJD0tHk2hNp075ww+qwvlnEDYU9W+3s2DIR8rT3dE XjKJ4kBTICI7f3GXKi2mClfSNsQ45zkhW/omShDMNYqnuHjJnrgpnZoxOQ7aZRj3beaI ug4JAIk8Sqt6nMz2KPH/AWxMg6PnR9mHYTZzygPpogadNQpFQd2M1khz+p7fB2e+2fcK DhY0S4hmoduTRTcEKzfQpEx/B9sBqlOo2HHCxeMOQNeLS3cYe9YKTC/Ia7mIZ9OfGYIX y2mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=BJ/YYsuNIbnrU+VciY8vRtjSRRmZS02NlaSW8WmZSe4=; b=bT55TyN0iDhTaB3VJf32GmeGJmOltrSaQwxs5ySLuwJ4Y0Qi5gWEUioG/Ll+aP3jT+ OEVJVn7QRz2ugYwo9D/hCiQRAMlUuH6Qdp3zeCJFGaVj9GkJK3iQigPA5P7/sgT67jUF 3xHTjjwa8A3gCtPxotCttVwEaw01dIIhpTmcflRVw/XI2Am/ZunYZJKae0wPmaEiOfFM /0H3NS4FUf5v7c/ATy1z3nhKaDwSgX5jUfdhe1PQ0p8AvrQ06piFncEznKK5DegDV7+I vxAF23bF+4SZE/44SyI8rjB/VDKCbph312sSaGhqFiVx3NJmpj44eY4KZH+N+mYDEgvg kDlQ== X-Gm-Message-State: ALKqPwfnclqiZacw47TMvwaewjD8V3wY0mij+UgBxigta4odiGh4mt3e qsobaD3nbVPf58RAqwwNBOPM7G1XKg== X-Received: by 2002:a37:1f14:: with SMTP id f20-v6mr9504662qkf.391.1526668133775; Fri, 18 May 2018 11:28:53 -0700 (PDT) Received: from kmo-pixel (c-71-234-172-214.hsd1.vt.comcast.net. [71.234.172.214]) by smtp.gmail.com with ESMTPSA id h3-v6sm5868029qkf.86.2018.05.18.11.28.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 May 2018 11:28:52 -0700 (PDT) Date: Fri, 18 May 2018 14:28:49 -0400 From: Kent Overstreet To: Josef Bacik Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Andrew Morton , Dave Chinner , darrick.wong@oracle.com, tytso@mit.edu, linux-btrfs@vger.kernel.org, clm@fb.com, jbacik@fb.com, viro@zeniv.linux.org.uk, willy@infradead.org, peterz@infradead.org Subject: Re: [PATCH 00/10] RFC: assorted bcachefs patches Message-ID: <20180518182849.GF31737@kmo-pixel> References: <20180518074918.13816-1-kent.overstreet@gmail.com> <20180518174536.ai26bg3bhlvzq4pi@destiny> <20180518174912.GE31737@kmo-pixel> <20180518180324.ymwbajfw5wsfrlth@destiny> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180518180324.ymwbajfw5wsfrlth@destiny> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 18, 2018 at 02:03:25PM -0400, Josef Bacik wrote: > There's nothing stopping us from doing that, it just uses a kprobe to override > the function with our helper, so we could conceivably put it anywhere in the > function. The reason I limited it to individual functions was because it was > easier than trying to figure out the side-effects of stopping mid-function. If > I needed to fail mid-function I just added a helper where I needed it and failed > that instead. I imagine safety is going to be of larger concern if we allow bpf > scripts to randomly return anywhere inside a function, even if the function is > marked as allowing error injection. Thanks, Ahh no, that's not what I want... here's an example: https://evilpiepirate.org/git/bcachefs.git/tree/fs/bcachefs/btree_cache.c#n674 Here we've got to do this thing which can race - which is fine, we just need to check for and handle the race, on line 709 - but actually exercising that with a test is difficult since it requires a heavily multithreaded workload with btree nodes getting evicted to see it happen, so - it pretends the race happened if race_fault() returns true. The race_fault() invocation shows up in debugfs, where userspace can tell it to fire. the way it works is dynamic_fault() is a macro that expands to a static struct dfault_descriptor, stuck in a particular linker section so the dynamic fault code can find them and stick them in debugfs (which is also the way dynamic debug works). #define dynamic_fault(_class) \ ({ \ static struct _dfault descriptor \ __used __aligned(8) __attribute__((section("__faults"))) = { \ .modname = KBUILD_MODNAME, \ .function = __func__, \ .filename = __FILE__, \ .line = __LINE__, \ .class = _class, \ }; \ \ static_key_false(&descriptor.enabled) && \ __dynamic_fault_enabled(&descriptor); \ }) Honestly it still seems like the cleanest and safest way of doing it to me...